1
2008-03-01 00:00:00
1259.985563
2
2008-03-01 01:00:00 < /td>
td>>1095.541500
< /tr>
3 < /td>
2008-03-01 02:00:00 < /td>
2008-03-01 02:00:00 < /td> />1056.247500
< /tr>
4 < /td>
2008-03-01 03:00:00 < /td>
1034.742000> < /td>
1034.742000> < />
1034.742000 /> 5 < /td>
2008-03-01 04:00:00 < /td>
1026.334500
< /tr>
< /tbody>
< /> table>
< /div>
dataSet decistemet для Decistemet и Demitemet для Decietemet и Dementire и Demitemet и Demitemet and CompityTemet и Demitemet и Demitemet и Demitemet. Object и float64 dtypes. Я хочу предсказать энергию, используя столбец DateTime в качестве единой функции.
Я использовал следующий код
Код: Выделить всё
train['datetime'] = pd.to_datetime(train['datetime'])
X = train.iloc[:,0]
y = train.iloc[:,-1]
< /code>
Я не смог передать единую функцию в качестве серии объекту Fit, так как я получил следующую ошибку. < /p>
ValueError: Expected 2D array, got 1D array instead:
array=['2008-03-01T00:00:00.000000000' '2008-03-01T01:00:00.000000000'
'2008-03-01T02:00:00.000000000' ... '2018-12-31T21:00:00.000000000'
'2018-12-31T22:00:00.000000000' '2018-12-31T23:00:00.000000000'].
Reshape your data either using array.reshape(-1, 1) if your data has a single feature or
array.reshape(1, -1) if it contains a single sample.
< /code>
Поэтому я преобразовал их формы, как предложено. < /p>
X = np.array(X).reshape(-1,1)
y = np.array(y).reshape(-1,1)
from sklearn.linear_model import LinearRegression
model_1 = LinearRegression()
model_1.fit(X,y)
test = pd.to_datetime(test['datetime'])
test = np.array(test).reshape(-1,1)
predictions = model_1.predict(test)
TypeError: The DType could not be promoted by .
This means that no common DType exists for the given inputs.
For example they cannot be stored in a single array unless the dtype is `object`.
The full list of DTypes is: (, )
< /code>
Я не могу обернуть голову вокруг этой ошибки. Как я могу использовать значения DateTime в качестве единой функции и применить простую линейную регрессию для прогнозирования целевого значения и прогнозирования времени времени? Где я делаю не так?
Подробнее здесь: https://stackoverflow.com/questions/744 ... orecasting