Python
1import pandas as pd 2import numpy as np 3import mglearn 4import matplotlib.pyplot as plt 5from sklearn.model_selection import train_test_split 6from sklearn.svm import LinearSVC 7 8csv_titanic = pd.read_csv("titanic_train.csv") 9 10# 読み取ったファイルを欠陥値処理やダミー変数化をして前処理を行った(中略) 11 12X = csv_titanic[["Age","Fare"]] 13y = csv_titanic["Survived"] #0と1のラベル 14 15X_train,X_test,y_train, y_test=train_test_split(X, y, stratify=y ) 16 17svm = LinearSVC().fit(X_train,y_train) 18plt.figure() 19mglearn.plots.plot_2d_separator(svm,X) 20 21 22TypeError: unhashable type: 'slice'
mglearn.plots.plot_2d_separator(svm,X)を上のコードで使用すると、
unhashable type: 'slice'
というエラーが表示されます。
上のコードでX,yともにsliceにはなっていないと思うのですが何が原因なのでしょうか?
よろしくお願いします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2020/04/17 09:49
2020/04/17 10:08