1
- # this file defines *and* loads one module
2
-
3
1
module Constant
4
2
5
- export ConstantRegressor, ConstantClassifier
6
- export DeterministicConstantRegressor, DeterministicConstantClassifier
3
+ using .. MLJBase, .. Tables
4
+ using Distributions
7
5
8
- import MLJBase
9
- import MLJBase. nrows
10
- import Distributions
11
- using StatsBase
12
- using Statistics
13
- using CategoricalArrays
14
- using ScientificTypes
6
+ export ConstantRegressor, ConstantClassifier,
7
+ DeterministicConstantRegressor, DeterministicConstantClassifier
15
8
16
9
# # THE CONSTANT REGRESSOR
17
10
@@ -23,7 +16,7 @@ probability distribution best fitting the training target data. Use
23
16
`predict_mean` to predict the mean value instead.
24
17
25
18
"""
26
- struct ConstantRegressor{D} <: MLJBase.Probabilistic
19
+ struct ConstantRegressor{D} <: MLJBase.Probabilistic
27
20
distribution_type:: Type{D}
28
21
end
29
22
function ConstantRegressor (; distribution_type= Distributions. Normal)
@@ -62,8 +55,8 @@ MLJBase.package_uuid(::Type{<:ConstantRegressor}) =
62
55
" d491faf4-2d78-11e9-2867-c94bc002c0b7"
63
56
MLJBase. package_url (:: Type{<:ConstantRegressor} ) = " https://github.com/alan-turing-institute/MLJModels.jl"
64
57
MLJBase. is_pure_julia (:: Type{<:ConstantRegressor} ) = true
65
- MLJBase. input_scitype (:: Type{<:ConstantRegressor} ) = Table (Scientific) # anything goes
66
- MLJBase. target_scitype (:: Type{<:ConstantRegressor} ) = AbstractVector{Continuous}
58
+ MLJBase. input_scitype (:: Type{<:ConstantRegressor} ) = MLJBase . Table (MLJBase . Scientific) # anything goes
59
+ MLJBase. target_scitype (:: Type{<:ConstantRegressor} ) = AbstractVector{MLJBase . Continuous}
67
60
68
61
69
62
# # THE CONSTANT DETERMINISTIC REGRESSOR (FOR TESTING)
@@ -85,8 +78,8 @@ MLJBase.package_name(::Type{<:DeterministicConstantRegressor}) = MLJBase.package
85
78
MLJBase. package_uuid (:: Type{<:DeterministicConstantRegressor} ) = MLJBase. package_url (ConstantRegressor)
86
79
MLJBase. package_url (:: Type{<:DeterministicConstantRegressor} ) = MLJBase. package_url (ConstantRegressor)
87
80
MLJBase. is_pure_julia (:: Type{<:DeterministicConstantRegressor} ) = true
88
- MLJBase. input_scitype (:: Type{<:DeterministicConstantRegressor} ) = Table (Scientific) # anything goes
89
- MLJBase. target_scitype (:: Type{<:DeterministicConstantRegressor} ) = AbstractVector{Continuous}
81
+ MLJBase. input_scitype (:: Type{<:DeterministicConstantRegressor} ) = MLJBase . Table (MLJBase . Scientific) # anything goes
82
+ MLJBase. target_scitype (:: Type{<:DeterministicConstantRegressor} ) = AbstractVector{MLJBase . Continuous}
90
83
91
84
92
85
# # THE CONSTANT CLASSIFIER
@@ -104,7 +97,7 @@ obtain the training target mode instead.
104
97
struct ConstantClassifier <: MLJBase.Probabilistic end
105
98
106
99
function MLJBase. fit (model:: ConstantClassifier ,
107
- verbosity:: Int , X, y)
100
+ verbosity:: Int , X, y)
108
101
109
102
fitresult = Distributions. fit (MLJBase. UnivariateFinite, y)
110
103
@@ -127,8 +120,8 @@ MLJBase.package_name(::Type{<:ConstantClassifier}) = MLJBase.package_name(Consta
127
120
MLJBase. package_uuid (:: Type{<:ConstantClassifier} ) = MLJBase. package_uuid (ConstantRegressor)
128
121
MLJBase. package_url (:: Type{<:ConstantClassifier} ) = MLJBase. package_url (ConstantRegressor)
129
122
MLJBase. is_pure_julia (:: Type{<:ConstantClassifier} ) = true
130
- MLJBase. input_scitype (:: Type{<:ConstantClassifier} ) = Table (Scientific) # anything goes
131
- MLJBase. target_scitype (:: Type{<:ConstantClassifier} ) = AbstractVector{<: Finite }
123
+ MLJBase. input_scitype (:: Type{<:ConstantClassifier} ) = MLJBase . Table (MLJBase . Scientific) # anything goes
124
+ MLJBase. target_scitype (:: Type{<:ConstantClassifier} ) = AbstractVector{<: MLJBase. Finite }
132
125
133
126
134
127
# # DETERMINISTIC CONSTANT CLASSIFIER (FOR TESTING)
@@ -161,13 +154,9 @@ MLJBase.package_name(::Type{<:DeterministicConstantClassifier}) = MLJBase.packag
161
154
MLJBase. package_uuid (:: Type{<:DeterministicConstantClassifier} ) = MLJBase. package_uuid (ConstantRegressor)
162
155
MLJBase. package_url (:: Type{<:DeterministicConstantClassifier} ) = MLJBase. package_url (ConstantRegressor)
163
156
MLJBase. is_pure_julia (:: Type{<:DeterministicConstantClassifier} ) = true
164
- MLJBase. input_scitype (:: Type{<:DeterministicConstantClassifier} ) = Table (Scientific) # anything goes
165
- MLJBase. target_scitype (:: Type{<:DeterministicConstantClassifier} ) = AbstractVector{<: Finite }
166
-
157
+ MLJBase. input_scitype (:: Type{<:DeterministicConstantClassifier} ) = MLJBase. Table (MLJBase. Scientific) # anything goes
158
+ MLJBase. target_scitype (:: Type{<:DeterministicConstantClassifier} ) = AbstractVector{<: MLJBase.Finite }
167
159
168
- end # module
169
-
170
-
171
- # # EXPOSE THE INTERFACE
160
+ end
172
161
173
- using . Constant
162
+ using MLJModels . Constant
0 commit comments