前提・実現したいこと
決定木分析のやり方を、あるサイトをみながら(https://analysis-navi.com/?p=2007)勉強しています。
発生している問題・エラーメッセージ
下記のようにコード入力しました。
import numpy as np
import pandas as pd
df_past = pd.read_csv("user_data.csv")
X_name = ["sex", "student", "stay time"]
y_name = ["registration"]
X = df_past[X_name]
y = df_past[y_name]
from sklearn.datasets import *
from sklearn import tree
from dtreeviz.trees import *
import graphviz
dtree = tree.DecisionTreeClassifier(max_depth=2)
dtree.fit(X,y)
上記のコードによって、
DecisionTreeClassifier(ccp_alpha=0.0, class_weight=None, criterion='gini',
max_depth=2, max_features=None, max_leaf_nodes=None,
min_impurity_decrease=0.0, min_impurity_split=None,
min_samples_leaf=1, min_samples_split=2,
min_weight_fraction_leaf=0.0, presort='deprecated',
random_state=None, splitter='best')
と無事出力されました。さらに、下記ようにコードを入力したのですが、図がうまく出力されません。
viz = dtreeviz(dtree,X,y,
target_name = 'registration',
feature_names = X_name,
class_names = ["Not Register","Register"])
viz
下記がエラーメッセージとなります。エラーの意味があまりに分からずで何が原因か教えていただけますと幸いです。
エラーメッセージ FileNotFoundError Traceback (most recent call last) /opt/anaconda3/lib/python3.7/site-packages/graphviz/backend/execute.py in run_check(cmd, input_lines, encoding, capture_output, quiet, **kwargs) 84 else: ---> 85 proc = subprocess.run(cmd, **kwargs) 86 except OSError as e: /opt/anaconda3/lib/python3.7/subprocess.py in run(input, capture_output, timeout, check, *popenargs, **kwargs) 487 --> 488 with Popen(*popenargs, **kwargs) as process: 489 try: /opt/anaconda3/lib/python3.7/subprocess.py in __init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, encoding, errors, text) 799 errread, errwrite, --> 800 restore_signals, start_new_session) 801 except: /opt/anaconda3/lib/python3.7/subprocess.py in _execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, start_new_session) 1550 err_msg += ': ' + repr(err_filename) -> 1551 raise child_exception_type(errno_num, err_msg, err_filename) 1552 raise child_exception_type(err_msg) FileNotFoundError: [Errno 2] No such file or directory: 'dot': 'dot' The above exception was the direct cause of the following exception: ExecutableNotFound Traceback (most recent call last) /opt/anaconda3/lib/python3.7/site-packages/IPython/core/formatters.py in __call__(self, obj) 343 method = get_real_method(obj, self.print_method) 344 if method is not None: --> 345 return method() 346 return None 347 else: /opt/anaconda3/lib/python3.7/site-packages/dtreeviz/trees.py in _repr_svg_(self) 35 36 def _repr_svg_(self): ---> 37 return self.svg() 38 39 def svg(self): /opt/anaconda3/lib/python3.7/site-packages/dtreeviz/trees.py in svg(self) 39 def svg(self): 40 """Render tree as svg and return svg text.""" ---> 41 svgfilename = self.save_svg() 42 with open(svgfilename, encoding='UTF-8') as f: 43 svg = f.read() /opt/anaconda3/lib/python3.7/site-packages/dtreeviz/trees.py in save_svg(self) 52 tmp = tempfile.gettempdir() 53 svgfilename = os.path.join(tmp, f"DTreeViz_{os.getpid()}.svg") ---> 54 self.save(svgfilename) 55 return svgfilename 56 /opt/anaconda3/lib/python3.7/site-packages/dtreeviz/trees.py in save(self, filename) 80 graphviz.backend.run(cmd, capture_output=True, check=True, quiet=False) 81 else: ---> 82 graphviz.backend.execute.run_check(cmd, capture_output=True, check=True, quiet=False) 83 84 if filename.endswith(".svg"): /opt/anaconda3/lib/python3.7/site-packages/graphviz/backend/execute.py in run_check(cmd, input_lines, encoding, capture_output, quiet, **kwargs) 86 except OSError as e: 87 if e.errno == errno.ENOENT: ---> 88 raise ExecutableNotFound(cmd) from e 89 raise 90 ExecutableNotFound: failed to execute 'dot', make sure the Graphviz executables are on your systems' PATH Out[33]: <dtreeviz.trees.DTreeViz at 0x7fb4d683d4d0> ### 該当のソースコード ```ここに言語名を入力 ソースコード
試したこと
ここに問題に対して試したことを記載してください。
補足情報(FW/ツールのバージョンなど)
ここにより詳細な情報を記載してください。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。