Created
July 14, 2018 05:08
-
-
Save mnofresno/9f7a58fba853157f01016540a75a8f04 to your computer and use it in GitHub Desktop.
Pequeño clasificador de ejemplo para aprender machine learning
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 = [[130, 6],[140, 9],[150, 90],[170, 777], [900,555]] | |
labels = [[0, 0], [0, 0], [1, 0], [1, 1], [2, 2]] | |
classifier = tree.DecisionTreeClassifier() | |
colorDictionary = {0: 'roja', 1:'verde', 2:'azul'} | |
typeDictionary = {0: 'naranja', 1: 'manzana', 2: 'pera'} | |
trainedClassifier = classifier.fit(features, labels) | |
prediction = trainedClassifier.predict([[100,9999]]); | |
print('Type Prediction: ', typeDictionary[prediction[0][0]], ' Color Prediction: ', colorDictionary[prediction[0][1]]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment