你好,我尝试用我的 csv 数据表创建决策树。我使用以下命令在 anaconda 和 python 中安装了 graphviz 包:
conda install graphviz
pip install graphviz
Run Code Online (Sandbox Code Playgroud)
让我的树可见。这是我在 Jupyther Notebook 中编写的代码:
import pandas as pd
import graphviz
from sklearn import metrics
from sklearn.tree import DecisionTreeClassifier, export_graphviz
from sklearn.model_selection import train_test_split
file = 'automotive_data.csv'
COLS = np.arange(0,22,1).tolist()#gibt später bei usecols eine andere möglichkeit die spalten anzusprechen
data = pd.read_csv(file, header=0, sep = ",", index_col=0, usecols=COLS)
x = data.iloc[:,1:]
x = x.to_numpy()
y = data[['Ausfall']]
y
xTrain, xTest, yTrain, yTest = train_test_split(x, y, test_size=0.3, …Run Code Online (Sandbox Code Playgroud)