Create predictions. Start a vw process. Convert data to vw format and send. Returns class probability estimates for the given test data. X : pandas dataframe or array-like Test samples Returns ------- proba : array-like, shape = (n_samp
(self,X)
| 313 | |
| 314 | |
| 315 | def predict_proba(self,X): |
| 316 | """Create predictions. Start a vw process. Convert data to vw format and send. |
| 317 | Returns class probability estimates for the given test data. |
| 318 | |
| 319 | X : pandas dataframe or array-like |
| 320 | Test samples |
| 321 | |
| 322 | Returns |
| 323 | ------- |
| 324 | proba : array-like, shape = (n_samples, n_outputs) |
| 325 | Class probability estimates. |
| 326 | |
| 327 | Caveats : |
| 328 | 1. A seldon specific fork of wabbit_wappa is needed to allow vw to run in server mode without save_resume. Save_resume seems to cause issues with the scores returned. Maybe connected to https://github.com/JohnLangford/vowpal_wabb#it/issues/262 |
| 329 | """ |
| 330 | self._start_vw_if_needed("test") |
| 331 | if isinstance(X,pd.DataFrame): |
| 332 | df = X |
| 333 | df_base = self._exclude_include_features(df) |
| 334 | df_base = df_base.fillna(0) |
| 335 | else: |
| 336 | check_array(X) |
| 337 | df_base = pd.DataFrame(X) |
| 338 | df_vw = df_base.apply(self._convert_row,axis=1) |
| 339 | predictions = None |
| 340 | for (index,val) in df_vw.iteritems(): |
| 341 | prediction = self.vw.send_line(val,parse_result=True) |
| 342 | self._start_raw_predictions() |
| 343 | scores = self._get_full_scores() |
| 344 | if predictions is None: |
| 345 | predictions = np.array([scores]) |
| 346 | else: |
| 347 | predictions = np.vstack([predictions,scores]) |
| 348 | return predictions |