Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

scikit learn decision tree

from sklearn import tree
X = [[0, 0], [1, 1]]
Y = [0, 1]
clf = tree.DecisionTreeClassifier()
clf = clf.fit(X, Y)
Comment

scikit decision tree

from sklearn import tree
X = [[0, 0], [2, 2]]
y = [0.5, 2.5]
clf = tree.DecisionTreeRegressor()
clf = clf.fit(X, y)
clf.predict([[1, 1]])
Comment

scikit decision tree

>>> from sklearn.datasets import load_iris
>>> from sklearn import tree
>>> iris = load_iris()
>>> X, y = iris.data, iris.target
>>> clf = tree.DecisionTreeClassifier()
>>> clf = clf.fit(X, y)
Comment

scikit learn decision tree

dot_data = tree.export_graphviz(clf, out_file=None, 
                     feature_names=iris.feature_names,  
                     class_names=iris.target_names,  
                     filled=True, rounded=True,  
                     special_characters=True)  
graph = graphviz.Source(dot_data)  
graph
Comment

PREVIOUS NEXT
Code Example
Python :: how to capitalize words in python 
Python :: changing database of django 
Python :: install python 3 
Python :: python append list to list 
Python :: hide grid imshow 
Python :: add text in figure coordinatesp ython 
Python :: pandas series create 
Python :: gdscript fixed decimal 
Python :: get sum of column before a date python 
Python :: check how many days old file is python 
Python :: iterative binary search 
Python :: how to get all distinct substrings in a string python 
Python :: position text in a box matplotlib 
Python :: how to use import command in python 
Python :: printing coloured and bold text in python 
Python :: python Cerberus 
Python :: get every second elemnt of array matlab 
Python :: DJANGO model instance get by variable 
Python :: copy module in python 
Python :: python int to scientific string 
Python :: Flask / Python. Get mimetype from uploaded file 
Python :: flatten list in python 
Python :: numpy random entries not repeat 
Python :: permutation in python 
Python :: django-storages delete folder 
Python :: del df.loc 
Python :: fastest way to compute pair wise distances python 
Python :: pyad create user 
Python :: eia api python 
Python :: python c like struct 
ADD CONTENT
Topic
Content
Source link
Name
8+1 =