sklearn: Found input variables with inconsistent numbers of samples: [1, 99]
Referring to the sklearn documentation for LinearRegression
(http://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LinearRegression.html#sklearn.linear_model.LinearRegression.fit), the X
vector needs to conform to the specification [n_samples,n_features]
.
Since you have only a single feature with many samples, the shape should be (99,1) - e.g., a single value per "row" with a single "column".
There are many ways to accomplish this (ref: Efficient way to add a singleton dimension to a NumPy vector so that slice assignments work), in your case, the following should work:
regressor.fit(x[:, None], y)
Don't forget that predict
requires the same shape to the data!