Python Forum
Help with linearRegression/cross_val_score
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help with linearRegression/cross_val_score
#1
Question 
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 :)
   
Reply
#2
Please show what you have tried (code) so far.
Reply
#3
(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)

Attached Files

Thumbnail(s)
   
Reply
#4
(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.
I have attached the data, code as well as the output. Kindly help if possible. Thanks :)

sorry, but have You understood what cv does ???
how many scores You thought 5 folds cv would returns??
Reply
#5
(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.
I have attached the data, code as well as the output. Kindly help if possible. Thanks :)

sorry, but have You understood what cv does ???
how many scores You thought 5 folds cv would returns??


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
Reply
#6
(May-20-2021, 08:24 PM)vasu2798 Wrote:
(May-20-2021, 08:08 PM)Caprone Wrote: sorry, but have You understood what cv does ???
how many scores You thought 5 folds cv would returns??


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

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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Type error in Cross_val_score Vicral 0 1,806 Jul-20-2021, 12:18 PM
Last Post: Vicral

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020