尝试拟合逻辑回归模型,但收到以下错误:
值错误: 错误的输入形状 (330, 5(
from sklearn.model_selection import train_test_split
X = ad_data[['Daily Time Spent on Site','Age','Area Income','Daily Internet Usage','Male']]
y= ad_data['Clicked on Ad']
X_train, y_train, X_test, y_test = train_test_split(X,y,test_size=0.33,random_state=42)
logmodel = LogisticRegression()
logmodel.fit(X_train,y_train)
错误不是很详细,但我认为您应该train_test_split
这样分配它:
X_train, X_test, y_train, y_test = train_test_split(X,y,test_size=0.33,random_state=42)
参考:https://scikit-learn.org/stable/modules/generated/sklearn.model_selection.train_test_split.html