Help with linearRegression/cross_val_score - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Data Science (https://python-forum.io/forum-44.html) +--- Thread: Help with linearRegression/cross_val_score (/thread-33679.html) |
Help with linearRegression/cross_val_score - vasu2798 - May-16-2021 Hi. I'm trying to find the cross validation score using Linear regression model but am getting scores more than 1. I have attached the data, code as well as the output. Kindly help if possible. Thanks :) [attachment=1061] RE: Help with linearRegression/cross_val_score - Larz60+ - May-17-2021 Please show what you have tried (code) so far. RE: Help with linearRegression/cross_val_score - vasu2798 - May-17-2021 (May-17-2021, 03:48 PM)Larz60+ Wrote: Please show what you have tried (code) so far. Hi!Please find the code below. A big Thanks for your time! :) import pandas as pd data=pd.read_csv(r'C:\Users\Personal\Desktop\Sample.csv',nrows=30) data from sklearn.linear_model import LinearRegression from sklearn.model_selection import cross_val_score import numpy as np lr=LinearRegression() x,y=data.iloc[:,0:2],data.iloc[:,[2]] lr=LinearRegression() cross_val_score(lr, x, y,cv=5) RE: Help with linearRegression/cross_val_score - Caprone - May-20-2021 (May-16-2021, 02:45 PM)vasu2798 Wrote: Hi. I'm trying to find the cross validation score using Linear regression model but am getting scores more than 1. sorry, but have You understood what cv does ??? how many scores You thought 5 folds cv would returns?? RE: Help with linearRegression/cross_val_score - vasu2798 - May-20-2021 (May-20-2021, 08:08 PM)Caprone Wrote:(May-16-2021, 02:45 PM)vasu2798 Wrote: Hi. I'm trying to find the cross validation score using Linear regression model but am getting scores more than 1. Hey Sorry. I guess I didn't frame my question right. I'm getting cv score values more than 1. I thought they would be in the range between 0.0 to 1.0 RE: Help with linearRegression/cross_val_score - Caprone - May-21-2021 (May-20-2021, 08:24 PM)vasu2798 Wrote:(May-20-2021, 08:08 PM)Caprone Wrote: sorry, but have You understood what cv does ??? ok if your metric is R2 than a score greater than 1 does not make sense; this may be because your data sample is very small, then variance can be very high; try to post a reproducible code with representative data |