Main
In [ ]:
Copied!
#------------------------------------------------------------
# -
# - Hello world, ML
# - 27-07-2020
# - aD
#-------------------------------------------------------------
!/usr/bin/env python3
from sklearn import tree
#------------------------------------------------------------
# -
# - Hello world, ML
# - 27-07-2020
# - aD
#-------------------------------------------------------------
!/usr/bin/env python3
from sklearn import tree
In [ ]:
Copied!
#test
print ("My first Neural Network\n")
#test
print ("My first Neural Network\n")
In [ ]:
Copied!
""" ======== SUPERVISED LEARNING STRUCTURE =============
|--------| |-----------| |-----------|
|Collect | |Train | |Make |
|Training| => |Classifier | => |Predictions|
| Data | | | | |
|--------| |-----------| |-----------|
"""
""" ======== SUPERVISED LEARNING STRUCTURE =============
|--------| |-----------| |-----------|
|Collect | |Train | |Make |
|Training| => |Classifier | => |Predictions|
| Data | | | | |
|--------| |-----------| |-----------|
"""
In [ ]:
Copied!
""" Colleting input datas """
#Initial values
#features = [[140,"smooth"], [130,"smooth"], [150,"bumpy"], [170,"bumpy"]]
#labels = ["apple", "apple", "orange", "orange"]
""" Colleting input datas """
#Initial values
#features = [[140,"smooth"], [130,"smooth"], [150,"bumpy"], [170,"bumpy"]]
#labels = ["apple", "apple", "orange", "orange"]
In [ ]:
Copied!
"""scikit-learn uses real-valued features """
#smooth : 1
#bumpy : 0
features = [[140, 1], [130, 1], [150, 0], [170, 0]]
#apple : 0
#orange :1
labels = [0, 0, 1, 1]
"""scikit-learn uses real-valued features """
#smooth : 1
#bumpy : 0
features = [[140, 1], [130, 1], [150, 0], [170, 0]]
#apple : 0
#orange :1
labels = [0, 0, 1, 1]
In [ ]:
Copied!
""" Train Classifier (Box of RULES) """
""" Train Classifier (Box of RULES) """
In [ ]:
Copied!
""" Decison Tree
weight > 150?
/ \
yes / \ No
Texture == bumby ?
/ \
yes / \ No
Orange apple
"""
""" Decison Tree
weight > 150?
/ \
yes / \ No
Texture == bumby ?
/ \
yes / \ No
Orange apple
"""
In [ ]:
Copied!
# creating a model
clf = tree.DecisionTreeClassifier()
# creating a model
clf = tree.DecisionTreeClassifier()
In [ ]:
Copied!
# training
#fit : find pattern in data
clf = clf.fit(features, labels)
# training
#fit : find pattern in data
clf = clf.fit(features, labels)
In [ ]:
Copied!
# prediction
print (clf.predict([[150, 0]]))
# prediction
print (clf.predict([[150, 0]]))
In [ ]:
Copied!