scikit-learn - TypeError: fit() 缺少 1 个必需的位置参数:'y'

import numpy as np

import pandas as pd


dataset=pd.read_csv("/Users/rushirajparmar/Downloads/Social_network_Ads.csv",error_bad_lines = False)



X = dataset.iloc[:,[2,3]].values.  

Y = dataset.iloc[:,4].values


from sklearn.model_selection import train_test_split

X_train,X_test,Y_train,Y_test = train_test_split(X,Y,test_size =  0.25,random_state = 0) 


from sklearn.preprocessing import StandardScaler

sc = StandardScaler()

X_train = sc.fit_transform(X_train)

X_test = sc.transform(X_test)


from sklearn.linear_model import LogisticRegression

classifier = LogisticRegression()

classifier.fit(X_train,Y_train)


y_pred = classifier.fit(X_test)


from sklearn.metrics import confusion_matrix

cm = confusion_matrix(Y_test, y_pred)

我刚开始练习 LogisticRegression 时出现此错误。我不明白出了什么问题。我尝试在互联网上搜索它,但没有帮助


y_pred = classifier.fit(X_test).values.ravel()


TypeError: fit() missing 1 required positional argument: 'y'

下面是数据集的链接:


https://github.com/Avik-Jain/100-Days-Of-ML-Code/blob/master/datasets/Social_Network_Ads.csv



慕姐8265434
浏览 476回答 2
2回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python