Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def exploit(self, X):
return self._score_avg(X)
def predict(self, X):
### Thompson sampling
if self.percentile is None:
pred = self._score_rnd(X)
### Upper confidence bound
else:
pred = self._score_max(X)
return pred
class _BootstrappedClassifier_w_predict_proba(_BootstrappedClassifierBase):
def _get_score(self, sample, X):
return self.bs_algos[sample].predict_proba(X)[:, 1]
class _BootstrappedClassifier_w_decision_function(_BootstrappedClassifierBase):
def _get_score(self, sample, X):
pred = self.bs_algos[sample].decision_function(X).reshape(-1)
_apply_sigmoid(pred)
return pred
class _BootstrappedClassifier_w_predict(_BootstrappedClassifierBase):
def _get_score(self, sample, X):
return self.bs_algos[sample].predict(X).reshape(-1)
class _OneVsRest:
def __init__(self, base, X, a, r, n, thr, alpha, beta, smooth=False, assume_un=False,
partialfit=False, force_fit=False, force_counters=False, njobs=1):
else:
pred = self._score_max(X)
return pred
class _BootstrappedClassifier_w_predict_proba(_BootstrappedClassifierBase):
def _get_score(self, sample, X):
return self.bs_algos[sample].predict_proba(X)[:, 1]
class _BootstrappedClassifier_w_decision_function(_BootstrappedClassifierBase):
def _get_score(self, sample, X):
pred = self.bs_algos[sample].decision_function(X).reshape(-1)
_apply_sigmoid(pred)
return pred
class _BootstrappedClassifier_w_predict(_BootstrappedClassifierBase):
def _get_score(self, sample, X):
return self.bs_algos[sample].predict(X).reshape(-1)
class _OneVsRest:
def __init__(self, base, X, a, r, n, thr, alpha, beta, smooth=False, assume_un=False,
partialfit=False, force_fit=False, force_counters=False, njobs=1):
if 'predict_proba' not in dir(base):
base = _convert_decision_function_w_sigmoid(base)
if partialfit:
base = _add_method_predict_robust(base)
if isinstance(base, list):
self.base = None
self.algos = base
else:
self.base = base
self.algos = [deepcopy(base) for i in range(n)]
def predict(self, X):
### Thompson sampling
if self.percentile is None:
pred = self._score_rnd(X)
### Upper confidence bound
else:
pred = self._score_max(X)
return pred
class _BootstrappedClassifier_w_predict_proba(_BootstrappedClassifierBase):
def _get_score(self, sample, X):
return self.bs_algos[sample].predict_proba(X)[:, 1]
class _BootstrappedClassifier_w_decision_function(_BootstrappedClassifierBase):
def _get_score(self, sample, X):
pred = self.bs_algos[sample].decision_function(X).reshape(-1)
_apply_sigmoid(pred)
return pred
class _BootstrappedClassifier_w_predict(_BootstrappedClassifierBase):
def _get_score(self, sample, X):
return self.bs_algos[sample].predict(X).reshape(-1)
class _OneVsRest:
def __init__(self, base, X, a, r, n, thr, alpha, beta, smooth=False, assume_un=False,
partialfit=False, force_fit=False, force_counters=False, njobs=1):
if 'predict_proba' not in dir(base):
base = _convert_decision_function_w_sigmoid(base)
if partialfit:
base = _add_method_predict_robust(base)