次のPythonプログラムを実行すると、
警告文「VisibleDeprecationWarning」が出ます。
どうしたら警告文が消えますか?
[警告エラー]
/usr/local/lib/python3.7/dist-packages/numpy/core/_asarray.py:83: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray
return array(a, dtype, copy=False, order=order)
[プログラム]
!pip install dtreeviz
from sklearn.tree import DecisionTreeClassifier
from dtreeviz.trees import *
import graphviz
data = np.array([[8,8,1],[50,40,1],[8,9,0],[15,12,1],[9,9.8,0]])
df = pd.DataFrame(data, columns = ["weight", "height", "label"])
x = df.drop("label", axis=1)
y = df["label"]
model=DecisionTreeClassifier(max_depth=2)
model.fit(x, y)
viz=dtreeviz(model, x, y, target_name="label", feature_names=["weight", "height"],class_names=["neko","inu"])
viz
あなたの回答
tips
プレビュー