MCPcopy Create free account
hub / github.com/SeldonIO/seldon-server / predict_proba

Method predict_proba

python/seldon/vw.py:315–348  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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

Callers 8

test_create_featuresMethod · 0.95
test_dict_featureMethod · 0.95
test_list_featureMethod · 0.95
test_vw_argsMethod · 0.95
test_numpy_inputMethod · 0.95

Calls 5

_start_vw_if_neededMethod · 0.95
_get_full_scoresMethod · 0.95
applyMethod · 0.45

Tested by 8

test_create_featuresMethod · 0.76
test_dict_featureMethod · 0.76
test_list_featureMethod · 0.76
test_vw_argsMethod · 0.76
test_numpy_inputMethod · 0.76