社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
Py学习  »  Python

Python逻辑回归中scikit学习中的巨大而奇怪的错误?

adriano1212 • 6 年前 • 2432 次点击  

我给你最重要的代码示例:

predictions = logistic_regression.predict(X_test)
prediction=logistic_regression.predict_proba(X_test)[:,:]
prediction=pd.DataFrame(data=predictions, 
                         columns=['Prob of Bad credit (0)','Prob of Good credit (1)'])
prediction.head(10)

昨天我得到了符合我期望的结果:

enter image description here

但今天,我完全不知道为什么,当我想再次运行这段代码时,出现了一个错误:

ValueError: Shape of passed values is (300, 1), indices imply (300, 2)

完全错误屏幕如下:

enter image description here

print(predictions)

[1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 0 1 1 1 1 0 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 0 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

我不希望在表中有1或0,我希望在屏幕中有1或0的概率百分比

从下面的源代码来看,在预测结束时的同一个表中,有相同的代码,它可以工作: https://www.kaggle.com/neisha/heart-disease-prediction-using-logistic-regression

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/55817
文章 [ 1 ]  |  最新文章 6 年前