Commit 9558aba2 authored by Manuel Günther's avatar Manuel Günther
Browse files

Tried to speed-up the scoring process; fixed small bug

parent 7e011d68
......@@ -27,6 +27,7 @@ import numpy
import trainers
import losses
import scipy.optimize
import itertools
......@@ -261,6 +262,7 @@ class BoostMachine():
"""Returns the indices of the features that are selected by the weak classifiers."""
return sorted(list(self.selected_indices))
def __call__(self, feature):
"""Returns the predicted score for the given single feature, assuming only single output.
......@@ -268,7 +270,7 @@ class BoostMachine():
Output: A single floating point number
"""
return sum([a * weak.get_weak_score(feature) for (a, weak) in zip(self.alpha, self.weak_trainer)])
return sum([a * weak.get_weak_score(feature) for (a, weak) in itertools.izip(self.alpha, self.weak_trainer)])
def classify(self, test_features):
......
......@@ -23,6 +23,8 @@ class StumpMachine():
self.threshold = threshold
self.polarity = polarity
self.selected_indices = selected_indices
if isinstance(self.selected_indices, int):
self.selected_indices = numpy.array([self.selected_indices], dtype=numpy.int)
def get_weak_scores(self,test_features):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment