社区所有版块导航
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

错误文件“<ipython-input-88-aaa9a8a07a7b>”,第12行y掼u predict=column掼u或掼1d(y,warn=True)^缩进错误:意外缩进

Khalil • 5 年前 • 310 次点击  

第一个错误是:

当你有1D时需要2D

意外缩进

我的代码是:

from sklearn import metrics
    from sklearn.linear_model import LogisticRegression

    model=LogisticRegression(solver="liblinear")

    #x_train=x_train.values.reshape(-1,1)
    #y_train=y_train.values.reshape(-1,1)
    model.fit(x_train,y_train)

    y_predict=model.predict(y_test)
    y_predict = y_predict.values.reshape(-1,1)
     y_predict = column_or_1d(y, warn=True)
    coef_df=pd.DataFrame(model_coef_)
    coef_df['intercept']=model_intercept_

    print(coef_df)
Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/56800
 
310 次点击  
文章 [ 1 ]  |  最新文章 5 年前
Make42
Reply   •   1 楼
Make42    5 年前

关于第一个错误

请检查尺寸 x_train y_train 通过跑步

print(x_train.shape)
print(y_train.shape)

形状 应该是 (nb_samples, nb_features) ,而 你的火车 应该是 (nb_samples,) -但我想,错在 . 请一行接一行地运行并发布,然后显示相应的错误。

关于第二个错误

据我所见,第二个错误是由于第一行到第二行的缩进。我编辑了您的问题,以便您可以看到如何将代码粘贴到stackoverflow中。我猜那是你的密码?