Skip to content

Commit

Permalink
Added Multilayer Perceptron (sklearn) (TheAlgorithms#1609)
Browse files Browse the repository at this point in the history
* Added Multilayer Perceptron ( sklearn)

* Rename MLPClassifier.py to multilayer_preceptron_classifier.py

* Rename multilayer_preceptron_classifier.py to multilayer_perceptron_classifier.py

* Update multilayer_perceptron_classifier.py
  • Loading branch information
QuantumNovice authored and cclauss committed Dec 3, 2019
1 parent 8ffc4f8 commit caad744
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions machine_learning/multilayer_perceptron_classifier.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from sklearn.neural_network import MLPClassifier


X = [[0.0, 0.0], [1.0, 1.0], [1.0, 0.0], [0.0, 1.0]]
y = [0, 1, 0, 0]


clf = MLPClassifier(
solver="lbfgs", alpha=1e-5, hidden_layer_sizes=(5, 2), random_state=1
)

clf.fit(X, y)


test = [[0.0, 0.0], [0.0, 1.0], [1.0, 1.0]]
Y = clf.predict(test)


def wrapper(Y):
"""
>>> wrapper(Y)
[0, 0, 1]
"""
return list(Y)


if __name__ == "__main__":
import doctest

doctest.testmod()

0 comments on commit caad744

Please sign in to comment.