79734012

Date: 2025-08-13 07:46:20
Score: 0.5
Natty:
Report link

use .reshape(-1, 1)

import numpy as np
from sklearn.linear_model import LinearRegression

X = np.array([1, 2, 3, 4, 5]).reshape(-1, 1)  # Features
y = np.array([2, 4, 6, 8, 10]).reshape(-1, 1)  # Target
model = LinearRegression()
model.fit(X, y)

If you have a one dimensional array this step is mandatory.

Reasons:
  • Low length (0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Bending Rodriguez