ValueError: could not convert string to float: error 'text'

Asked 1 years ago, Updated 1 years ago, 106 views

I'm trying to process data about weather data, but I'm getting an error, so please let me know!

from sklearn.linear_model
import LinearRegression

model1=LinearRegression()

X=data
y=data2

model1.fit(X,y)
model1.coef_, model.intercept_

In one dataset, data is the region and data2 is the temperature. The execution result says could not convert string to float: 'Gyeonggi-do' How can I solve it?

python scikit-learn

2022-09-21 12:38

1 Answers

I don't know what data we can get from linear regression using region and temperature, but... {'Seoul': 1, 'Gyeonggi-do': 2,...} I think it would be possible if you match each region name with a number like this.

However, you need to have a specific relationship between the matched number and temperature to get meaningful results, so if you have to do linear regression with region and temperature, I think it's better to give a number that affects latitude or temperature than a random number.


2022-09-21 12:38

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.