为了账号安全,请及时绑定邮箱和手机立即绑定

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

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

慕姐8265434 2021-06-05 10:25:01
import numpy as npimport pandas as pddataset=pd.read_csv("/Users/rushirajparmar/Downloads/Social_network_Ads.csv",error_bad_lines = False)X = dataset.iloc[:,[2,3]].values.  Y = dataset.iloc[:,4].valuesfrom sklearn.model_selection import train_test_splitX_train,X_test,Y_train,Y_test = train_test_split(X,Y,test_size =  0.25,random_state = 0) from sklearn.preprocessing import StandardScalersc = StandardScaler()X_train = sc.fit_transform(X_train)X_test = sc.transform(X_test)from sklearn.linear_model import LogisticRegressionclassifier = LogisticRegression()classifier.fit(X_train,Y_train)y_pred = classifier.fit(X_test)from sklearn.metrics import confusion_matrixcm = 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
查看完整描述

2 回答

  • 2 回答
  • 0 关注
  • 470 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信