问题描述
如何将以下混淆矩阵导出到html,以使滑块仍处于活动状态?我尝试了几种方法,但都没有成功。谢谢!
我一直在练习以下代码(来自https://github.com/JNYH/diabetes_classifier):
bestmodel = gnb
def make_confusion_matrix(model,threshold=0.5):
y_pred = (bestmodel.predict_proba(X_test)[:,1] >= threshold)
conf = confusion_matrix(y_test,y_pred)
plt.figure(figsize = [6,6])
sns.heatmap(conf,cmap=plt.cm.Blues,annot=True,square=True,fmt='d',xticklabels=['no diabetes','diabetes'],yticklabels=['no diabetes','diabetes']);
plt.xlabel('prediction')
plt.ylabel('actual')
# To see how the confusion matrix changes with the cutoff!
from ipywidgets import interactive,FloatSlider
# bestmodel = LogisticRegression(C = optimal_c)
# bestmodel.fit(X_train,y_train)
interactive(lambda threshold: make_confusion_matrix(bestmodel,threshold),threshold=(0.0,1.0,0.01))
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)