Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- import juputer
- import sklearn
- import pandas as pd
- import matplotlib.pyplot as plt
- import dateset
- from SVM import svmlib
- from sklearn.tree import DecisionTreeReqressor
- from sklear.tree import export_graphviz
- from sklearn.datasets import load_iris
- from sklearn import tree
- #Инициализируем и распетываем набор данных
- datasetx = np.array(
- [[0],
- [2],
- [4],
- [6],
- [8],
- [10],
- [12],
- [14]])
- #print(datasetx)
- datasety = np.array(
- [[0],
- [0.92],
- [0.94],
- [0.96],
- [0.98],
- [1.00]])
- #print(datasety)
- #Выбираем строки и столбцы
- x = datasetx[:, 1:2].astype(int)
- y = datasety[:, 1:2].astype(int)
- #print(x)
- #Регрессор древа решений
- regressor = DecisionTreeReqressor(random_state = 0)
- regressor. fit(x, y)
- #Визуализация результата
- x_grid = np.arange(min(x), max(x), 0.01)
- x_grid = x_grid.reshape((len(x_grid), 1))
- plt.plot(x_grid, refressir.predict(x_grid), color = 'blue')
- plt.text(8, 1.70, r'Accuracy of the training set')
- plt.text(8, 1.50, r'accuracy of the test set')
- plt.show()
- #Древо
- clf = tree.DecisionTreeClassifier()
- iris = load_iris()
- clf = clf.fit(iris.data, iris.target)
- tree.export_graphviz(clf)
- 'digraph Tree' {"Uniformity of Cell size <= 2,5" -> "Bare Nuclei <= 3,5" [lable = "True"]
- "Uniformity of Cell size <= 2,5" -> "Bare Nuclei <= 7,5" [lable = "False"]
- "Bare Nuclei <= 3,5" -> "Single Epithelial Cell Size <= 2,5" [lable = "True"]
- "Single Epithelial Cell Size <= 2,5" -> "class = benign" [lable = "True"]
- "Single Epithelial Cell Size <= 2,5" -> "class = benign" [lable = "False"]
- "Bare Nuclei <= 3,5" -> "class = malignant" [lable = "False"]
- "Bare Nuclei <= 7,5" -> "Uniformity of Cell size <= 6,5" [lable = "True"]
- "Uniformity of Cell size <= 6,5" -> "class = malignant" [lable = "True"]
- "Uniformity of Cell size <= 6,5" -> "class = malignant" [lable = "False"]
- "Bare Nuclei <= 7,5" -> "Bland Chomathin <= 3,5" [lable = "False"]
- "Bland Chomathin <= 3,5" -> "class = malignant" [lable = "True"]
- "Bland Chomathin <= 3,5" -> "class = malignant" [lable = "False"]
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement