'Error using ransac.predict(line_X.reshape(1,-1))
I wrote this code - using housing data from kaggle:
X = df['RM'].values.reshape(-1,1)
y = df['MEDV'].values
from sklearn.linear_model import RANSACRegressor
ransac = RANSACRegressor()
ransac.fit(X,y)
inlier_mask = ransac.inlier_mask_
outlier_mask = np.logical_not(inlier_mask)
np.arange(3,10,1)
line_X = np.arange(3,10,1)
line_y_ransac = ransac.predict(line_X.reshape(1,-1))
I got this error on line_y:
ValueError: matmul: Input operand 1 has a mismatch in its core dimension 0, with gufunc signature (n?,k),(k,m?)->(n?,m?) (size 1 is different from 7)
Solution 1:[1]
I found the problem. I should've passed -1, 1 instead of 1, -1 to line_X.reshape:
line_X.reshape(-1,1))
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
