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

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 get max value and min values in entire dataframe 
Python :: Adding Route In Django 
Python :: how to chose version of python 
Python :: list of list to numpy array 
Python :: python print main arguments 
Python :: matplotlib boxplot change size of outliers 
Python :: how to get the output in rupees in pandas 
Python :: python cast number to between 0 and 1 
Python :: hide verbose in pip install 
Python :: cv2 remove black borders on images 
Python :: binary search iterative python 
Python :: triplets in python 
Python :: min stack in python 
Python :: save model with best validation loss keras 
Python :: how to create a numpy array linspace in python 
Python :: run a shell script from python 
Python :: change period to timestamp python 
Python :: add last item of array at the first index of the array python 
Python :: default dictionary value 
Python :: Return array of odd rows and even columns from array using numpy 
Python :: ljust rjust center python 
Python :: numpy sort multidimensional array 
Python :: python time a task 
Python :: combinations 
Python :: python += dictionary 
Python :: python how to write array into matlab file 
Python :: getting last n rows of column 
Python :: how to block empty space python login 
Python :: avoid bad request django 
Python :: pandas get highest values column 
ADD CONTENT
Topic
Content
Source link
Name
8+8 =