如何解决如何将使用Ipywidget-Interactive制作的混淆矩阵导出到html或gif?
如何将以下混淆矩阵导出到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 举报,一经查实,本站将立刻删除。