Created
October 14, 2016 15:57
-
-
Save marcoscastro/d89050faf443082d3fe0c4740994312f to your computer and use it in GitHub Desktop.
Exemplo árvore decisão com Python e sklearn
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sklearn import tree | |
features = [[140, 1], [130, 1], | |
[150, 0], [170, 0]] | |
labels = [0, 0, 1, 1] # 0 é maçã e 1 é laranja | |
# o classificador encontra padrões nos dados de treinamento | |
clf = tree.DecisionTreeClassifier() # instância do classificador | |
clf = clf.fit(features, labels) # fit encontra padrões nos dados | |
# iremos utilizar para classificar uma nova fruta | |
print(clf.predict([[150, 0]])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment