我正在尝试建立一个逻辑回归模型,但它显示了一个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)