Python ModuleNotFoundError:没有名为';熊猫';
我试图运行教程中的代码,以便更好地理解它。我已经完成了一半,但在粘贴这行代码时,我收到一条错误消息,上面说:Python ModuleNotFoundError:没有名为';熊猫';,python,python-3.x,Python,Python 3.x,我试图运行教程中的代码,以便更好地理解它。我已经完成了一半,但在粘贴这行代码时,我收到一条错误消息,上面说: ModuleNotFoundError:没有名为“熊猫”的模块 代码如下: from pandas_confusion import ConfusionMatrix def iterate_fit_predict_score(number_runs): f1_scores = [] y = reformat(student_data['passed'])
ModuleNotFoundError:没有名为“熊猫”的模块
代码如下:
from pandas_confusion import ConfusionMatrix
def iterate_fit_predict_score(number_runs):
f1_scores = []
y = reformat(student_data['passed'])
for num in range(0,number_runs):
X_train, X_test, y_train, y_test = Stratified_Shuffle_Split(X_all, y, num_test)
clf_SVC = SVC()
parameters = [{'C':[1,10,50,100,200,300,400,500,1000],
'gamma':[1e-4, 1e-3, 1e-2, 1e-1, 1e0, 1e1],
'kernel': ['rbf']}]
clf = GridSearchCV(clf_SVC, parameters, scoring = 'f1')
clf.fit(X_train, y_train)
y_true, y_pred = y_test, clf.predict(X_test)
target_names = ["failed","passed"]
print(classification_report(y_true, y_pred,target_names=target_names))
# Print Conf_Matrix
conf_matrix = pd.crosstab(y_true, y_pred, rownames=['Actual'], colnames=['Predicted'], margins=True)
print("\nConf_Matrix:", conf_matrix)
#Normalize Conf_Matrix:
conf_matrix_norm = conf_matrix / conf_matrix.sum(axis=1)
print("\nNormalize Conf_Matrix:", conf_matrix_norm)
#Generate Confusion Matrix Plot
conf_matrix = metrics.confusion_matrix(y_true, y_pred)
labels = ['fail','pass']
pl.title('SVC: Confusion Matrix')
ax = pl.axes
sns.heatmap(conf_matrix,
xticklabels=labels,
yticklabels=labels,
annot=True, fmt='')
pl.xlabel("Predicted")
pl.ylabel("True")
这是什么意思?无论如何,这是我下面要介绍的内容,以防您想看到完整的代码,因为您缺少pandas\u混淆包。在命令提示符下,运行pip install pandas\u conflusion
您必须创建模块pandas\u conflusion
,因为我记得库中没有提供该模块。如何创建该模块?该模块可能是在教程中创建的,并且具有ConfusionMatrix
类。请阅读一些有关该语言的基础知识,如