I always find myself reshaping my data when I'm working with sklearn
, and it's irritating and makes my code ugly. Why can't the library be made to work with a variety of data shapes, interpreting appropriately? For example, to work with a linear regressor I need to do
from sklearn.linear_model import LinearRegression
x = np.random.rand(10).reshape(-1,1)
y = np.random.rand(10).reshape(-1,1)
regr = LinearRegression()
regr.fit(x,y)
but if I want to use a support vector regressor, then I don't reshape the independent variable:
from sklearn.svm import SVR
x = np.random.rand(10).reshape(-1,1)
y = np.random.rand(10)
regr = SVR()
regr.fit(x,y)
I presume there is some reason why the library is designed in this way; can anyone illuminate me?