scikit-learn-contrib / lightning

Large-scale linear classification, regression and ranking in Python
https://contrib.scikit-learn.org/lightning/
1.73k stars 214 forks source link

2d errors when passing pandas DataFrame/Series #149

Open simpsus opened 3 years ago

simpsus commented 3 years ago

training is a pd.DataFrame features is a list of column names

model = AdaGradRegressor() model.fit(training[features], training['target']) throws ~\Anaconda3\envs\numerai\lib\site-packages\lightning\impl\adagrad.py in fit(self, X, y) 130 def fit(self, X, y): 131 self.outputs2d = len(y.shape) > 1 --> 132 Y = y.reshape(-1, 1) if not self.outputs2d else y 133 Y = Y.astype(np.float64) 134 return self._fit(X, Y)

~\Anaconda3\envs\numerai\lib\site-packages\pandas\core\generic.py in getattr(self, name) 5137 if self._info_axis._can_hold_identifiers_and_holds_name(name): 5138 return self[name] -> 5139 return object.getattribute(self, name) 5140 5141 def setattr(self, name: str, value) -> None:

AttributeError: 'Series' object has no attribute 'reshape'

when I pass training['target'].values it works. My normal scikit-learn workflow is to pass the pandas objects and that never is an issue.

model.predict(training[features]) has the same issue