Skip to content
This repository has been archived by the owner on Jul 10, 2021. It is now read-only.

Commit

Permalink
Revert some changes that were mismerged in previous commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexjc committed Apr 11, 2015
1 parent a6f3989 commit 2b4135e
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions sknn/mlp.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,16 +416,18 @@ def predict(self, X):

class MultiLayerPerceptronClassifier(BaseMLP, sklearn.base.ClassifierMixin):


#def __convert_to_output(self, ):

def _setup(self):
self.label_binarizer = sklearn.preprocessing.LabelBinarizer()
self.label_pipeline = sklearn.pipeline.Pipeline([
('binarizer', self.label_binarizer),
('encoder', sklearn.preprocessing.OneHotEncoder(sparse=False))])


def fit(self, X, y):
# Scan training samples to find all different classes.
self.label_pipeline.fit(y)
yp = self.label_pipeline.transform(y)
self.label_binarizer.fit(y)
yp = self.label_binarizer.transform(y)

# Now train based on a problem transformed into regression.
return super(MultiLayerPerceptronClassifier, self)._fit(X, yp, test=y)

Expand Down Expand Up @@ -467,5 +469,4 @@ def predict(self, X):
The predicted classes, or the predicted values.
"""
y = self.predict_proba(X)
y_ml = y.argmax(1)
return self.label_binarizer.inverse_transform(y_ml)
return self.label_binarizer.inverse_transform(y, threshold=0.5)

0 comments on commit 2b4135e

Please sign in to comment.