Skip to content
Snippets Groups Projects
Commit 6f6060b7 authored by Alexandre Gramfort's avatar Alexandre Gramfort
Browse files

Logistic : adding properties to get access to coef_ and intercept_

coef_ is now a vector of size n_features (the intercept is left out)

git-svn-id: https://scikit-learn.svn.sourceforge.net/svnroot/scikit-learn/trunk@684 22fbfee3-77ab-4535-9bad-27d1bd3bc7d8
parent 18d20abe
Branches
Tags
No related merge requests found
...@@ -16,7 +16,7 @@ class LogisticRegression(object): ...@@ -16,7 +16,7 @@ class LogisticRegression(object):
def fit(self, X, Y): def fit(self, X, Y):
X = np.asanyarray(X, dtype=np.float64, order='C') X = np.asanyarray(X, dtype=np.float64, order='C')
Y = np.asanyarray(Y, dtype=np.int32, order='C') Y = np.asanyarray(Y, dtype=np.int32, order='C')
self.coef_, self.label_, self.bias_ = liblinear.train_wrap(X, self.coef_with_intercept_, self.label_, self.bias_ = liblinear.train_wrap(X,
Y, self.solver_type, self.eps, 1.0, Y, self.solver_type, self.eps, 1.0,
self.C, 0, self.C, 0,
self._weight_label, self._weight_label,
...@@ -24,7 +24,7 @@ class LogisticRegression(object): ...@@ -24,7 +24,7 @@ class LogisticRegression(object):
def predict(self, T): def predict(self, T):
T = np.asanyarray(T, dtype=np.float64, order='C') T = np.asanyarray(T, dtype=np.float64, order='C')
return liblinear.predict_wrap(T, self.coef_, self.solver_type, return liblinear.predict_wrap(T, self.coef_with_intercept_, self.solver_type,
self.eps, self.C, self.eps, self.C,
self._weight_label, self._weight_label,
self._weight, self.label_, self._weight, self.label_,
...@@ -32,8 +32,17 @@ class LogisticRegression(object): ...@@ -32,8 +32,17 @@ class LogisticRegression(object):
def predict_proba(self, T): def predict_proba(self, T):
T = np.asanyarray(T, dtype=np.float64, order='C') T = np.asanyarray(T, dtype=np.float64, order='C')
return liblinear.predict_prob_wrap(T, self.coef_, self.solver_type, return liblinear.predict_prob_wrap(T, self.coef_with_intercept_, self.solver_type,
self.eps, self.C, self.eps, self.C,
self._weight_label, self._weight_label,
self._weight, self.label_, self._weight, self.label_,
self.bias_) self.bias_)
@property
def intercept_(self):
return self.coef_with_intercept_[:,-1]
@property
def coef_(self):
return self.coef_with_intercept_[:,:-1]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment