0

I built my first model - linear reggression.

from sklearn import linear_model
regr= linear_model.LinearRegression()
train_x =np.asanyarray(train['Data'])
train_y= np.asanyarray(train['Zachorowania'])
regr.fit(train_x,train_y)
regr.coef_ 

Format "Data" is not correct (this is object), what format should I use to use "fit" function? For instance: 4 mar 2020
6 mar 2020
7 mar 2020

Still I have an errror: "could not convert string to float: '4 mar 2020"

Ola Radys
  • 19
  • 2
  • 1
    you'll have to convert the date string to datetime dtype, see [pd.to_datetime](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.to_datetime.html), and then to some appropriate numeric value to use as x, see also [this](https://stackoverflow.com/q/29748717/10197418). – FObersteiner Oct 18 '20 at 13:09
  • Please also provide [reproducible sample data](https://stackoverflow.com/questions/20109391). Otherwise potential answerers cannot test. – Bill Huang Oct 18 '20 at 17:16

0 Answers0