@@ -18,33 +18,33 @@ def _huber_loss_and_gradient(w, X, y, epsilon, alpha, sample_weight=None):
18
18
19
19
Parameters
20
20
----------
21
- w: ndarray, shape (n_features + 1,) or (n_features + 2,)
21
+ w : ndarray, shape (n_features + 1,) or (n_features + 2,)
22
22
Feature vector.
23
- w[:n_features] gives the feature vector
23
+ w[:n_features] gives the coefficients
24
24
w[-1] gives the scale factor and if the intercept is fit w[-2]
25
25
gives the intercept factor.
26
26
27
- X: ndarray, shape (n_samples, n_features)
27
+ X : ndarray, shape (n_samples, n_features)
28
28
Input data.
29
29
30
- y: ndarray, shape (n_samples,)
30
+ y : ndarray, shape (n_samples,)
31
31
Target vector.
32
32
33
- epsilon: float
33
+ epsilon : float
34
34
Robustness of the Huber estimator.
35
35
36
- alpha: float
36
+ alpha : float
37
37
Regularization parameter.
38
38
39
- sample_weight: ndarray, shape (n_samples,), optional
39
+ sample_weight : ndarray, shape (n_samples,), optional
40
40
Weight assigned to each sample.
41
41
42
42
Returns
43
43
-------
44
44
loss: float
45
45
Huber loss.
46
46
47
- gradient: ndarray, shape (n_features + 1,) or (n_features + 2, )
47
+ gradient: ndarray, shape (len(w) )
48
48
Returns the derivative of the Huber loss with respect to each
49
49
coefficient, intercept and the scale as a vector.
50
50
"""
@@ -129,8 +129,9 @@ class HuberRegressor(LinearModel, RegressorMixin, BaseEstimator):
129
129
``|(y - X'w) / sigma| < epsilon`` and the absolute loss for the samples
130
130
where ``|(y - X'w) / sigma| > epsilon``, where w and sigma are parameters
131
131
to be optimized. The parameter sigma makes sure that if y is scaled up
132
- or down by a certain factor, one does not need to rescale epsilon to acheive
133
- the same robustness.
132
+ or down by a certain factor, one does not need to rescale epsilon to
133
+ achieve the same robustness. Note that this does not take into account
134
+ the fact that the different features of X may be of different scales.
134
135
135
136
This makes sure that the loss function is not heavily influenced by the
136
137
outliers while not completely ignoring their effect.
@@ -141,11 +142,12 @@ class HuberRegressor(LinearModel, RegressorMixin, BaseEstimator):
141
142
----------
142
143
epsilon : float, greater than 1.0, default 1.35
143
144
The parameter epsilon controls the number of samples that should be
144
- classified as outliers. The lesser the epsilon, the more robust it is
145
+ classified as outliers. The smaller the epsilon, the more robust it is
145
146
to outliers.
146
147
147
148
max_iter : int, default 100
148
- Number of iterations that scipy.optimize.fmin_l_bfgs_b should run for.
149
+ Maximum number of iterations that scipy.optimize.fmin_l_bfgs_b
150
+ should run for.
149
151
150
152
alpha : float, default 0.0001
151
153
Regularization parameter.
@@ -174,7 +176,7 @@ class HuberRegressor(LinearModel, RegressorMixin, BaseEstimator):
174
176
scale_ : float
175
177
The value by which ``|y - X'w - c|`` is scaled down.
176
178
177
- n_iter_: int
179
+ n_iter_ : int
178
180
Number of iterations that fmin_l_bfgs_b has run for.
179
181
Not available if SciPy version is 0.9 and below.
180
182
@@ -207,7 +209,7 @@ def fit(self, X, y, sample_weight=None):
207
209
y : array-like, shape (n_samples,)
208
210
Target vector relative to X.
209
211
210
- sample_weight: array-like, shape (n_samples,)
212
+ sample_weight : array-like, shape (n_samples,)
211
213
Weight given to each sample.
212
214
213
215
Returns
@@ -225,7 +227,8 @@ def fit(self, X, y, sample_weight=None):
225
227
226
228
if self .epsilon < 1.0 :
227
229
raise ValueError (
228
- "epsilon should be greater than 1.0, got %f" % self .epsilon )
230
+ "epsilon should be greater than or equal to 1.0, got %f"
231
+ % self .epsilon )
229
232
230
233
if self .warm_start and hasattr (self , 'coef_' ):
231
234
parameters = np .concatenate (
0 commit comments