text_plain_output_1.png
from IPython.display import Image

from six import StringIO

from sklearn.datasets import load_iris

from sklearn.tree import DecisionTreeClassifier

from sklearn.tree import export_graphviz

import numpy as np

import pandas as pd

import pydotplus

iris = load_iris()
x = pd.DataFrame(data=iris.data, columns=iris.feature_names)
y = iris.target

from sklearn.tree import DecisionTreeClassifier
model = DecisionTreeClassifier(random_state=0)

model.fit(x_train, y_train)

y_pred = model.predict(x_test)

pred = pd.DataFrame({'Actual': y_test, 'Predicted': y_pred})
pred.to_csv('result.csv', index=False)

y_train_pred = model.predict(x_train)

data = []
for i in range(4):
    n = float(input())
    data.append(n)
data = np.reshape(data, (1, len(data)))

pred = model.predict(data)

from six import StringIO
from IPython.display import Image
from sklearn.tree import export_graphviz
import pydotplus
dot_data = StringIO()
export_graphviz(model, out_file=dot_data, feature_names=iris.feature_names, filled=True, rounded=True, special_characters=True)
graph = pydotplus.graph_from_dot_data(dot_data.getvalue())
Image(graph.create_png())