20
20
def get_auto_step_size (max_squared_sum , alpha_scaled , loss , fit_intercept ,
21
21
n_samples = None ,
22
22
is_saga = False ):
23
- """Compute automatic step size for SAG solver
23
+ """Compute automatic step size for SAG solver.
24
24
25
25
The step size is set to 1 / (alpha_scaled + L + fit_intercept) where L is
26
26
the max sum of squares for over all samples.
@@ -34,17 +34,17 @@ def get_auto_step_size(max_squared_sum, alpha_scaled, loss, fit_intercept,
34
34
Constant that multiplies the regularization term, scaled by
35
35
1. / n_samples, the number of samples.
36
36
37
- loss : string, in {" log", " squared" }
37
+ loss : {' log', ' squared', 'multinomial' }
38
38
The loss function used in SAG solver.
39
39
40
40
fit_intercept : bool
41
41
Specifies if a constant (a.k.a. bias or intercept) will be
42
42
added to the decision function.
43
43
44
- n_samples : int, optional
44
+ n_samples : int, default=None
45
45
Number of rows in X. Useful if is_saga=True.
46
46
47
- is_saga : boolean, optional
47
+ is_saga : bool, default=False
48
48
Whether to return step size for the SAGA algorithm or the SAG
49
49
algorithm.
50
50
@@ -91,7 +91,7 @@ def sag_solver(X, y, sample_weight=None, loss='log', alpha=1., beta=0.,
91
91
check_input = True , max_squared_sum = None ,
92
92
warm_start_mem = None ,
93
93
is_saga = False ):
94
- """SAG solver for Ridge and LogisticRegression
94
+ """SAG solver for Ridge and LogisticRegression.
95
95
96
96
SAG stands for Stochastic Average Gradient: the gradient of the loss is
97
97
estimated each sample at a time and the model is updated along the way with
@@ -113,17 +113,17 @@ def sag_solver(X, y, sample_weight=None, loss='log', alpha=1., beta=0.,
113
113
114
114
Parameters
115
115
----------
116
- X : {array-like, sparse matrix}, shape (n_samples, n_features)
117
- Training data
116
+ X : {array-like, sparse matrix} of shape (n_samples, n_features)
117
+ Training data.
118
118
119
- y : numpy array, shape (n_samples,)
119
+ y : ndarray of shape (n_samples,)
120
120
Target values. With loss='multinomial', y must be label encoded
121
121
(see preprocessing.LabelEncoder).
122
122
123
- sample_weight : array-like, shape (n_samples,), optional
123
+ sample_weight : array-like of shape (n_samples,), default=None
124
124
Weights applied to individual samples (1. for unweighted).
125
125
126
- loss : 'log' | 'squared' | 'multinomial'
126
+ loss : { 'log', 'squared', 'multinomial'}, default='log '
127
127
Loss function that will be optimized:
128
128
-'log' is the binary logistic loss, as used in LogisticRegression.
129
129
-'squared' is the squared loss, as used in Ridge.
@@ -133,40 +133,39 @@ def sag_solver(X, y, sample_weight=None, loss='log', alpha=1., beta=0.,
133
133
.. versionadded:: 0.18
134
134
*loss='multinomial'*
135
135
136
- alpha : float, optional
136
+ alpha : float, default=1.
137
137
L2 regularization term in the objective function
138
- ``(0.5 * alpha * || W ||_F^2)``. Defaults to 1.
138
+ ``(0.5 * alpha * || W ||_F^2)``.
139
139
140
- beta : float, optional
140
+ beta : float, default=0.
141
141
L1 regularization term in the objective function
142
142
``(beta * || W ||_1)``. Only applied if ``is_saga`` is set to True.
143
- Defaults to 0.
144
143
145
- max_iter : int, optional
144
+ max_iter : int, default=1000
146
145
The max number of passes over the training data if the stopping
147
- criteria is not reached. Defaults to 1000.
146
+ criteria is not reached.
148
147
149
- tol : double, optional
148
+ tol : double, default=0.001
150
149
The stopping criteria for the weights. The iterations will stop when
151
- max(change in weights) / max(weights) < tol. Defaults to .001
150
+ max(change in weights) / max(weights) < tol.
152
151
153
- verbose : integer, optional
152
+ verbose : int, default=0
154
153
The verbosity level.
155
154
156
- random_state : int, RandomState instance, default=None
155
+ random_state : int or RandomState instance, default=None
157
156
Used when shuffling the data. Pass an int for reproducible output
158
157
across multiple function calls.
159
158
See :term:`Glossary <random_state>`.
160
159
161
- check_input : bool, default True
160
+ check_input : bool, default= True
162
161
If False, the input arrays X and y will not be checked.
163
162
164
- max_squared_sum : float, default None
163
+ max_squared_sum : float, default= None
165
164
Maximum squared sum of X over samples. If None, it will be computed,
166
165
going through all the samples. The value should be precomputed
167
166
to speed up cross validation.
168
167
169
- warm_start_mem : dict, optional
168
+ warm_start_mem : dict, default=None
170
169
The initialization parameters used for warm starting. Warm starting is
171
170
currently used in LogisticRegression but not in Ridge.
172
171
It contains:
@@ -180,13 +179,13 @@ def sag_solver(X, y, sample_weight=None, loss='log', alpha=1., beta=0.,
180
179
- 'seen': array of boolean describing the seen samples.
181
180
- 'num_seen': the number of seen samples.
182
181
183
- is_saga : boolean, optional
182
+ is_saga : bool, default=False
184
183
Whether to use the SAGA algorithm or the SAG algorithm. SAGA behaves
185
184
better in the first epochs, and allow for l1 regularisation.
186
185
187
186
Returns
188
187
-------
189
- coef_ : array, shape (n_features)
188
+ coef_ : ndarray of shape (n_features, )
190
189
Weight vector.
191
190
192
191
n_iter_ : int
0 commit comments