Last answered:

04 Sept 2023

Posted on:

31 Aug 2023

0

SK Learn Regression Issue

How can I fix this code , it can't regress itself

I've been trying to use reg.get_params() , but it didn't work.

5 answers ( 0 marked as helpful)
Instructor
Posted on:

31 Aug 2023

0

Hi Eric!

Thanks for reaching out!

The error message you're encountering indicates that your data contains non-numeric values, such as strings or bytes, which are not compatible with scikit-learn's LinearRegression model that expects numeric input. To resolve this issue, you need to ensure that your input data is in a numeric format.

Please check if the data is properly preprocessed and doesn't contain categorical variables. Moreover, you can share the previous cells of your code for further assistance. 

Hope this helps.

Best,

Ivan

Posted on:

01 Sept 2023

0

Hi Ivan thanks for your reply , here's my previous cells

The strange thing is the cell is same as the solution , how can it works in the lecture but cannot works now ?

Instructor
Posted on:

01 Sept 2023

0

Hi Eric!

Can you please specify which is the course and the lesson you are referring to?

Looking forward to your answer.

Ivan

Posted on:

02 Sept 2023

0

Hi Ivan !

It's the course

"Complete Data Science Training: Mathematics, Statistics, Python, Advanced Statistics in Python, Machine & Deep Learning"

218.Multiple Linear Regression Exercise

Thanks for your attention !

Instructor
Posted on:

04 Sept 2023

0

Hi Eric!

The error you're encountering is due to the fact that you're passing a list of column names ('size' and 'year') as the input feature array x to the LinearRegression model's fit() function. The model expects numeric data in the x array, but you're providing column names which are strings.

Here's how you can modify your code to fix this issue:
x = data[['size', 'year']] 

y = data['price'] 

Hope this helps.

Best,

Ivan

Submit an answer