Skip to content

Instantly share code, notes, and snippets.

@erogol
Created November 14, 2014 11:05
Show Gist options
  • Save erogol/327b8255b5aa8d97bf87 to your computer and use it in GitHub Desktop.
Save erogol/327b8255b5aa8d97bf87 to your computer and use it in GitHub Desktop.
class LinearSVC_proba(LinearSVC):
def __platt_func(self,x):
return 1/(1+np.exp(-x))
def predict_proba(self, X):
f = np.vectorize(self.__platt_func)
raw_predictions = self.decision_function(X)
platt_predictions = f(raw_predictions)
probs = platt_predictions / platt_predictions.sum(axis=1)[:, None]
return probs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment