<jupyter_start><jupyter_text>![title](http://s5047.pcdn.co/wp-content/uploads/2015/04/iris_petal_sepal.png)<jupyter_code>iris_file = "iris.csv"
names = ['sepal-length', 'sepal-width', 'petal-length', 'petal-width', 'class']
dataset = pd.read_csv(iris_file, names=names)
dataset.head(10)
np.unique(dataset.iloc[:, -1].values)
colors = {'Iris-setosa':'r', 'Iris-versicolor':'g', 'Iris-virginica':'b'}
# create a figure and axis
fig, ax = plt.subplots()
# plot each data-point
for i in range(len(dataset['sepal-length'])):
    ax.scatter(dataset['sepal-length'][i], dataset['sepal-width'][i],color=colors[dataset['class'][i]])
# set a title and labels
ax.set_title('Iris Dataset')
ax.set_xlabel('sepal-length')
ax.set_ylabel('sepal-width')
# Simple DT machine learning model
X = dataset.iloc[:, 0:-1]
y = dataset.iloc[:, -1]
X.head()
y.head()<jupyter_output><empty_output><jupyter_text>Split your data<jupyter_code>X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.33, random_state=2)<jupyter_output><empty_output><jupyter_text>Simple machine learning model<jupyter_code>clf = tree.DecisionTreeClassifier()
clf = clf.fit(X_train, y_train)<jupyter_output><empty_output><jupyter_text>Train fit<jupyter_code>pred = clf.predict(X.iloc[0:1, 0:])
print(pred)
print([y[0]])
# test on unseen data
metrics.accuracy_score(clf.predict(X_test.iloc[0:, 0:]), y_test)
%matplotlib inline
plt.rcParams['figure.dpi'] = 150
tree.plot_tree(clf.fit(X_train, y_train))
plt.show()
## export the tree in Graphviz format using the export_graphviz (optional)
## graphviz export of the above tree trained on the entire iris dataset; the results are saved in an output file iris.pdf
dot_data = tree.export_graphviz(clf, out_file=None) 

graph = graphviz.Source(dot_data) 

os.listdir()
graph.render("iris")
list(X.columns)
dot_data = tree.export_graphviz(clf, out_file=None, 
                      feature_names=list(X.columns),  
                      class_names=names,  
                      filled=True, rounded=True,  
                      special_characters=True)  
graph = graphviz.Source(dot_data)  
graph<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1531615925058548, 'fraction_numerical': 0.013583138173302109, 'mean_word_length': 5.357142857142857, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '519602', 'license': 'MIT', 'n_tokens_mistral': 833, 'n_tokens_neox': 806, 'n_words': 142, 'path': 'Iris.ipynb', 'repo_name': 'AdaScience/PyBradford', 'size': '2135'}