Вот мой код:
`features = data.drop(["Tenure"], axis = 1)
target = data["Tenure"]
features = features.to_numpy()
target = target.to_numpy()
features_train, features_valid, target_train, target_valid = train_test_split(features, target, test_size = 0.25, random_state = 12345)
features_train = features_train.reshape(-1, 1)
target_train = target_train.reshape(-1, 1)
model_elastic = ElasticNetCV(random_state = 12345)
model_elastic.fit(features_train, target_train)
predictions = model_elastic.predict(target_train)
print(accuracy_score(target, predict))`
Ошибка:
ValueError Traceback (most recent call last)
<ipython-input-99-cb6d5d8978a1> in <module>
7 target_train = target_train.reshape(-1, 1)
8 model_elastic = ElasticNetCV(random_state = 12345)
----> 9 model_elastic.fit(features_train, target_train)
10 predictions = model_elastic.predict(features_train)
11 print(accuracy_score(target, predict))
~\anaconda3\envs\LikeProject\lib\site-packages\sklearn\linear_model\_coordinate_descent.py in fit(self, X, y)
1261
1262 if X.shape[0] != y.shape[0]:
-> 1263 raise ValueError("X and y have inconsistent dimensions (%d != %d)"
1264 % (X.shape[0], y.shape[0]))
1265
ValueError: X and y have inconsistent dimensions (68180 != 6818)
Сначала у меня была ошибка с 2d массивом, но я решил её с помощью преобразования dataframe в numpy array и reshape, и после этого у меня и появилась эта ошибка. Мне нужно предсказать значения для target_train.