2012/12/14 Olivier Grisel <[email protected]>: > 2012/12/14 Shishir Pandey <[email protected]>: >> Hi >> >> I am trying to trying to find the regression matrix \beta. In the following: >> >> Y = X \beta + \epsilon >> >> Y - m x n matrix. (sparse matrix) >> X - m x k matrix. (sparse matrix) >> \beta - k x n matrix >> >> I try to fit the SGDRegressor as fit(X,Y). It gives a value error: >> ValueError: Buffer has wrong number of dimensions (expected 1, got 2) >> >> I see in the documentation Y can only be a vector of type [n_samples]. Is >> there a way in which I can use SGDRegressor with Y being a matrix. > > Right now, the SGDRegressor linear model accepts a single output. You > will have to slice the Y matrix into column with shape `(n_samples,)` > and run `n_outputs` independent linear regression and then aggregate > the `coef_` vectors to find you beta matrix.
Alternatively you can use sklearn.linear_model.Ridge that supports multiple ouputs directly: http://scikit-learn.sourceforge.net/stable/modules/generated/sklearn.linear_model.Ridge.html#sklearn.linear_model.Ridge.fit (the website scikit-learn.org has a DNS issue, hence the direct link to the sourceforge page). -- Olivier http://twitter.com/ogrisel - http://github.com/ogrisel ------------------------------------------------------------------------------ LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial Remotely access PCs and mobile devices and provide instant support Improve your efficiency, and focus on delivering more value-add services Discover what IT Professionals Know. Rescue delivers http://p.sf.net/sfu/logmein_12329d2d _______________________________________________ Scikit-learn-general mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/scikit-learn-general
