小编Bic*_*ani的帖子

AttributeError:构建逻辑回归模型时,“str”对象没有属性“decode”

我正在尝试建立一个逻辑回归模型,但它显示了一个AttributeError: 'str' object has no attribute 'decode'. 请帮我解决这个问题。该代码在 Datacamp 的服务器上完美运行,但在我的笔记本电脑上显示 AttributeError。

import pandas as pd
df = pd.read_csv('datasets/diabetes.csv')
X = df.drop('diabetes',axis = 1)
y = df['diabetes']

# Import the necessary modules
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import classification_report, confusion_matrix

# Create training and test sets
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.4, random_state=42)

# Create the classifier: logreg
logreg = LogisticRegression()

# Fit the classifier to the training data
logreg.fit(X_train,y_train)
Run Code Online (Sandbox Code Playgroud)

错误信息:

---------------------------------------------------------------------------
AttributeError                            Traceback …
Run Code Online (Sandbox Code Playgroud)

python scikit-learn logistic-regression

5
推荐指数
1
解决办法
2474
查看次数

标签 统计

logistic-regression ×1

python ×1

scikit-learn ×1