67 lines
3.2 KiB
Plaintext
67 lines
3.2 KiB
Plaintext
Traceback (most recent call last):
|
|
File "/Users/mhjensen/opt/anaconda3/lib/python3.8/site-packages/jupyter_cache/executors/utils.py", line 51, in single_nb_execution
|
|
executenb(
|
|
File "/Users/mhjensen/opt/anaconda3/lib/python3.8/site-packages/nbclient/client.py", line 1087, in execute
|
|
return NotebookClient(nb=nb, resources=resources, km=km, **kwargs).execute()
|
|
File "/Users/mhjensen/opt/anaconda3/lib/python3.8/site-packages/nbclient/util.py", line 74, in wrapped
|
|
return just_run(coro(*args, **kwargs))
|
|
File "/Users/mhjensen/opt/anaconda3/lib/python3.8/site-packages/nbclient/util.py", line 53, in just_run
|
|
return loop.run_until_complete(coro)
|
|
File "/Users/mhjensen/opt/anaconda3/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
|
|
return future.result()
|
|
File "/Users/mhjensen/opt/anaconda3/lib/python3.8/site-packages/nbclient/client.py", line 540, in async_execute
|
|
await self.async_execute_cell(
|
|
File "/Users/mhjensen/opt/anaconda3/lib/python3.8/site-packages/nbclient/client.py", line 832, in async_execute_cell
|
|
self._check_raise_for_error(cell, exec_reply)
|
|
File "/Users/mhjensen/opt/anaconda3/lib/python3.8/site-packages/nbclient/client.py", line 740, in _check_raise_for_error
|
|
raise CellExecutionError.from_cell_and_msg(cell, exec_reply['content'])
|
|
nbclient.exceptions.CellExecutionError: An error occurred while executing the following cell:
|
|
------------------
|
|
import os
|
|
from sklearn.datasets import load_breast_cancer
|
|
from sklearn.tree import DecisionTreeClassifier
|
|
from sklearn.model_selection import train_test_split
|
|
from sklearn.metrics import confusion_matrix
|
|
from sklearn.tree import export_graphviz
|
|
|
|
from IPython.display import Image
|
|
from pydot import graph_from_dot_data
|
|
import pandas as pd
|
|
import numpy as np
|
|
|
|
|
|
cancer = load_breast_cancer()
|
|
X = pd.DataFrame(cancer.data, columns=cancer.feature_names)
|
|
print(X)
|
|
y = pd.Categorical.from_codes(cancer.target, cancer.target_names)
|
|
y = pd.get_dummies(y)
|
|
print(y)
|
|
X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=1)
|
|
tree_clf = DecisionTreeClassifier(max_depth=5)
|
|
tree_clf.fit(X_train, y_train)
|
|
|
|
export_graphviz(
|
|
tree_clf,
|
|
out_file="DataFiles/cancer.dot",
|
|
feature_names=cancer.feature_names,
|
|
class_names=cancer.target_names,
|
|
rounded=True,
|
|
filled=True
|
|
)
|
|
cmd = 'dot -Tpng DataFiles/cancer.dot -o DataFiles/cancer.png'
|
|
os.system(cmd)
|
|
------------------
|
|
|
|
[0;31m---------------------------------------------------------------------------[0m
|
|
[0;31mModuleNotFoundError[0m Traceback (most recent call last)
|
|
[0;32m<ipython-input-2-7c394b1e8b71>[0m in [0;36m<module>[0;34m[0m
|
|
[1;32m 7[0m [0;34m[0m[0m
|
|
[1;32m 8[0m [0;32mfrom[0m [0mIPython[0m[0;34m.[0m[0mdisplay[0m [0;32mimport[0m [0mImage[0m[0;34m[0m[0;34m[0m[0m
|
|
[0;32m----> 9[0;31m [0;32mfrom[0m [0mpydot[0m [0;32mimport[0m [0mgraph_from_dot_data[0m[0;34m[0m[0;34m[0m[0m
|
|
[0m[1;32m 10[0m [0;32mimport[0m [0mpandas[0m [0;32mas[0m [0mpd[0m[0;34m[0m[0;34m[0m[0m
|
|
[1;32m 11[0m [0;32mimport[0m [0mnumpy[0m [0;32mas[0m [0mnp[0m[0;34m[0m[0;34m[0m[0m
|
|
|
|
[0;31mModuleNotFoundError[0m: No module named 'pydot'
|
|
ModuleNotFoundError: No module named 'pydot'
|
|
|