@@ -7,17 +7,18 @@ const SymStr = Union{Symbol,String}
7
7
include (" regressors.jl" )
8
8
include (" classifiers.jl" )
9
9
10
- const REG_MODELS = (LinearRegressor, RidgeRegressor, LassoRegressor, ElasticNetRegressor,
11
- RobustRegressor, HuberRegressor, QuantileRegressor, LADRegressor)
10
+ const REG_MODELS = (LinearRegressor, RidgeRegressor, LassoRegressor,
11
+ ElasticNetRegressor, RobustRegressor, HuberRegressor,
12
+ QuantileRegressor, LADRegressor)
12
13
const CLF_MODELS = (LogisticClassifier, MultinomialClassifier)
13
14
const ALL_MODELS = (REG_MODELS... , CLF_MODELS... )
14
15
15
16
#= ==========
16
17
REGRESSORS
17
18
========== =#
18
19
19
- function MLJBase . fit (m:: Union{REG_MODELS...} , verb:: Int , X, y)
20
- Xmatrix = MLJBase . matrix (X)
20
+ function MMI . fit (m:: Union{REG_MODELS...} , verb:: Int , X, y)
21
+ Xmatrix = MMI . matrix (X)
21
22
reg = glr (m)
22
23
solver = m. solver === nothing ? _solver (reg, size (Xmatrix)) : m. solver
23
24
# get the parameters
@@ -26,9 +27,9 @@ function MLJBase.fit(m::Union{REG_MODELS...}, verb::Int, X, y)
26
27
return θ, nothing , NamedTuple {} ()
27
28
end
28
29
29
- MLJBase . predict (m:: Union{REG_MODELS...} , θ, Xnew) = apply_X (MLJBase . matrix (Xnew), θ)
30
+ MMI . predict (m:: Union{REG_MODELS...} , θ, Xnew) = apply_X (MMI . matrix (Xnew), θ)
30
31
31
- function MLJBase . fitted_params (m:: Union{REG_MODELS...} , θ)
32
+ function MMI . fitted_params (m:: Union{REG_MODELS...} , θ)
32
33
m. fit_intercept && return (coefs = θ[1 : end - 1 ], intercept = θ[end ])
33
34
return (coefs = θ, intercept = nothing )
34
35
end
37
38
CLASSIFIERS
38
39
=========== =#
39
40
40
- function MLJBase . fit (m:: Union{CLF_MODELS...} , verb:: Int , X, y)
41
- Xmatrix = MLJBase . matrix (X)
42
- yplain = convert .(Int, MLJBase . int (y))
43
- classes = MLJBase . classes (y[1 ])
41
+ function MMI . fit (m:: Union{CLF_MODELS...} , verb:: Int , X, y)
42
+ Xmatrix = MMI . matrix (X)
43
+ yplain = convert .(Int, MMI . int (y))
44
+ classes = MMI . classes (y[1 ])
44
45
nclasses = length (classes)
45
46
if nclasses == 2
46
47
# recode
@@ -58,21 +59,21 @@ function MLJBase.fit(m::Union{CLF_MODELS...}, verb::Int, X, y)
58
59
return (θ, c, classes), nothing , NamedTuple {} ()
59
60
end
60
61
61
- function MLJBase . predict (m:: Union{CLF_MODELS...} , (θ, c, classes), Xnew)
62
- Xmatrix = MLJBase . matrix (Xnew)
62
+ function MMI . predict (m:: Union{CLF_MODELS...} , (θ, c, classes), Xnew)
63
+ Xmatrix = MMI . matrix (Xnew)
63
64
preds = apply_X (Xmatrix, θ, c)
64
65
# binary classification
65
66
if c == 1
66
67
preds .= sigmoid .(preds)
67
68
preds = hcat (1.0 .- preds, preds) # scores for -1 and 1
68
- return [MLJBase . UnivariateFinite (classes, preds[i, :]) for i in 1 : size (Xmatrix,1 )]
69
+ return [MMI . UnivariateFinite (classes, preds[i, :]) for i in 1 : size (Xmatrix,1 )]
69
70
end
70
71
# multiclass
71
72
preds .= softmax (preds)
72
- return [MLJBase . UnivariateFinite (classes, preds[i, :]) for i in 1 : size (Xmatrix,1 )]
73
+ return [MMI . UnivariateFinite (classes, preds[i, :]) for i in 1 : size (Xmatrix,1 )]
73
74
end
74
75
75
- function MLJBase . fitted_params (m:: Union{CLF_MODELS...} , (θ, c, classes))
76
+ function MMI . fitted_params (m:: Union{CLF_MODELS...} , (θ, c, classes))
76
77
if c > 1
77
78
if m. fit_intercept
78
79
W = reshape (θ, div (length (θ), c), c)
90
91
METADATA FOR ALL MODELS
91
92
======================= =#
92
93
93
- MLJBase . metadata_pkg .(ALL_MODELS,
94
+ MMI . metadata_pkg .(ALL_MODELS,
94
95
name= " MLJLinearModels" ,
95
96
uuid= " 6ee0df7b-362f-4a72-a706-9e79364fb692" ,
96
97
url= " https://github.com/alan-turing-institute/MLJLinearModels.jl" ,
@@ -100,21 +101,21 @@ MLJBase.metadata_pkg.(ALL_MODELS,
100
101
101
102
descr_ (M) = descr (M) *
102
103
" \n → based on [MLJLinearModels](https://github.com/alan-turing-institute/MLJLinearModels.jl)" *
103
- " \n → do `@load $(MLJBase . name (M)) pkg=\" MLJLinearModels\" to use the model.`" *
104
- " \n → do `?$(MLJBase . name (M)) ` for documentation."
105
- lp_ (M) = " MLJLinearModels.$(MLJBase . name (M)) "
104
+ " \n → do `@load $(MMI . name (M)) pkg=\" MLJLinearModels\" to use the model.`" *
105
+ " \n → do `?$(MMI . name (M)) ` for documentation."
106
+ lp_ (M) = " MLJLinearModels.$(MMI . name (M)) "
106
107
107
108
for M in REG_MODELS
108
- MLJBase . metadata_model (M,
109
- input= MLJBase . Table (MLJBase . Continuous),
110
- target= AbstractVector{MLJBase . Continuous},
109
+ MMI . metadata_model (M,
110
+ input= MMI . Table (MMI . Continuous),
111
+ target= AbstractVector{MMI . Continuous},
111
112
weights= false ,
112
113
descr= descr_ (M), path= lp_ (M))
113
114
end
114
115
for M in CLF_MODELS
115
- MLJBase . metadata_model (M,
116
- input= MLJBase . Table (MLJBase . Continuous),
117
- target= AbstractVector{<: MLJBase .Finite },
116
+ MMI . metadata_model (M,
117
+ input= MMI . Table (MMI . Continuous),
118
+ target= AbstractVector{<: MMI .Finite },
118
119
weights= false ,
119
120
descr= descr_ (M), path= lp_ (M))
120
121
end
0 commit comments