@@ -6,14 +6,14 @@ export GeneralizedLinearRegression, GLR,
6
6
RobustRegression, HuberRegression, QuantileRegression
7
7
8
8
"""
9
- GeneralizedLinearRegression{L<:Loss, P<:Penalty}
9
+ GeneralizedLinearRegression{L<:Loss, P<:Penalty}
10
10
11
11
Generalized Linear Regression (GLR) model with objective function:
12
12
13
13
``L(y, Xθ) + P(θ)``
14
14
15
- where `L` is a loss function, `P` a penalty, `y` is the vector of observed response, `X` is
16
- the feature matrix and `θ` the vector of parameters.
15
+ where `L` is a loss function, `P` a penalty, `y` is the vector of observed
16
+ response, `X` is the feature matrix and `θ` the vector of parameters.
17
17
18
18
Special cases include:
19
19
@@ -74,8 +74,10 @@ $SIGNATURES
74
74
75
75
Objective function: ``|Xθ - y|₂²/2 + λ|θ|₂²/2 + γ|θ|₁``.
76
76
"""
77
- function ElasticNetRegression (λ:: Real = 1.0 , γ:: Real = 1.0 ; lambda:: Real = λ, gamma:: Real = γ,
78
- fit_intercept:: Bool = true , penalize_intercept:: Bool = false )
77
+ function ElasticNetRegression (λ:: Real = 1.0 , γ:: Real = 1.0 ;
78
+ lambda:: Real = λ, gamma:: Real = γ,
79
+ fit_intercept:: Bool = true ,
80
+ penalize_intercept:: Bool = false )
79
81
check_pos .((lambda, gamma))
80
82
GLR (penalty= lambda* L2Penalty ()+ gamma* L1Penalty (),
81
83
fit_intercept= fit_intercept,
@@ -108,10 +110,11 @@ end
108
110
"""
109
111
$SIGNATURES
110
112
111
- Objective function: ``L(y, Xθ) + λ|θ|₂²/2 + γ|θ|₁`` where `L` is either the logistic loss in the
112
- binary case or the multinomial loss otherwise.
113
+ Objective function: ``L(y, Xθ) + λ|θ|₂²/2 + γ|θ|₁`` where `L` is either the
114
+ logistic loss in the binary case or the multinomial loss otherwise.
113
115
"""
114
- function LogisticRegression (λ:: Real = 1.0 , γ:: Real = 0.0 ; lambda:: Real = λ, gamma:: Real = γ,
116
+ function LogisticRegression (λ:: Real = 1.0 , γ:: Real = 0.0 ;
117
+ lambda:: Real = λ, gamma:: Real = γ,
115
118
penalty:: Symbol = iszero (gamma) ? :l2 : :en ,
116
119
multi_class:: Bool = false , fit_intercept:: Bool = true ,
117
120
penalize_intercept:: Bool = false )
@@ -131,11 +134,13 @@ MultinomialRegression(a...; kwa...) = LogisticRegression(a...; multi_class=true,
131
134
"""
132
135
$SIGNATURES
133
136
134
- Objective function: ``∑ρ(Xθ - y) + λ|θ|₂² + γ|θ|₁`` where ρ is a given function on the residuals.
137
+ Objective function: ``∑ρ(Xθ - y) + λ|θ|₂² + γ|θ|₁`` where ρ is a given function
138
+ on the residuals.
135
139
"""
136
140
function RobustRegression (ρ:: RobustRho = HuberRho (0.1 ), λ:: Real = 1.0 , γ:: Real = 0.0 ;
137
141
rho:: RobustRho = ρ, lambda:: Real = λ, gamma:: Real = γ,
138
- penalty:: Symbol = iszero (gamma) ? :l2 : :en , fit_intercept:: Bool = true ,
142
+ penalty:: Symbol = iszero (gamma) ? :l2 : :en ,
143
+ fit_intercept:: Bool = true ,
139
144
penalize_intercept:: Bool = false )
140
145
penalty = _l1l2en (lambda, gamma, penalty, " Robust regression" )
141
146
GLR (loss= RobustLoss (rho),
@@ -151,12 +156,14 @@ Huber Regression with objective:
151
156
152
157
``∑ρ(Xθ - y) + λ|θ|₂²/2 + γ|θ|₁``
153
158
154
- Where `ρ` is the Huber function `ρ(r) = r²/2`` if `|r|≤δ` and `ρ(r)=δ(|r|-δ/2)` otherwise.
159
+ Where `ρ` is the Huber function `ρ(r) = r²/2`` if `|r|≤δ` and
160
+ `ρ(r)=δ(|r|-δ/2)` otherwise.
155
161
"""
156
162
function HuberRegression (δ:: Real = 0.5 , λ:: Real = 1.0 , γ:: Real = 0.0 ;
157
163
delta:: Real = δ, lambda:: Real = λ, gamma:: Real = γ,
158
164
penalty:: Symbol = iszero (gamma) ? :l2 : :en ,
159
- fit_intercept:: Bool = true , penalize_intercept:: Bool = false )
165
+ fit_intercept:: Bool = true ,
166
+ penalize_intercept:: Bool = false )
160
167
return RobustRegression (HuberRho (delta), lambda, gamma;
161
168
penalty= penalty, fit_intercept= fit_intercept,
162
169
penalize_intercept= penalize_intercept)
@@ -174,7 +181,8 @@ Where `ρ` is the check function `ρ(r) = r(δ - 1(r < 0))`.
174
181
function QuantileRegression (δ:: Real = 0.5 , λ:: Real = 1.0 , γ:: Real = 0.0 ;
175
182
delta:: Real = δ, lambda:: Real = λ, gamma:: Real = γ,
176
183
penalty:: Symbol = iszero (gamma) ? :l2 : :en ,
177
- fit_intercept:: Bool = true , penalize_intercept:: Bool = false )
184
+ fit_intercept:: Bool = true ,
185
+ penalize_intercept:: Bool = false )
178
186
return RobustRegression (QuantileRho (delta), lambda, gamma;
179
187
penalty= penalty, fit_intercept= fit_intercept,
180
188
penalize_intercept= penalize_intercept)
0 commit comments