@@ -208,6 +208,7 @@ class LogisticRegression(_GLM):
208
208
>>> X, y = make_classification()
209
209
>>> lr = LogisticRegression()
210
210
>>> lr.fit(X, y)
211
+ >>> lr.decision_function(X)
211
212
>>> lr.predict(X)
212
213
>>> lr.predict_proba(X)
213
214
>>> lr.score(X, y)"""
@@ -218,6 +219,21 @@ class LogisticRegression(_GLM):
218
219
def family (self ):
219
220
return families .Logistic
220
221
222
+ def decision_function (self , X ):
223
+ """Predict confidence scores for samples in X.
224
+
225
+ Parameters
226
+ ----------
227
+ X : array-like, shape = [n_samples, n_features]
228
+
229
+ Returns
230
+ -------
231
+ T : array-like, shape = [n_samples, n_classes]
232
+ The confidence score of the sample for each class in the model.
233
+ """
234
+ X_ = self ._check_array (X )
235
+ return dot (X_ , self ._coef )
236
+
221
237
def predict (self , X ):
222
238
"""Predict class labels for samples in X.
223
239
@@ -244,8 +260,7 @@ def predict_proba(self, X):
244
260
T : array-like, shape = [n_samples, n_classes]
245
261
The probability of the sample for each class in the model.
246
262
"""
247
- X_ = self ._check_array (X )
248
- return sigmoid (dot (X_ , self ._coef ))
263
+ return sigmoid (self .decision_function (X ))
249
264
250
265
def score (self , X , y ):
251
266
"""The mean accuracy on the given data and labels
0 commit comments