1
1
# Users of this module should first read the document
2
2
# https://alan-turing-institute.github.io/MLJ.jl/dev/adding_models_for_general_use/
3
-
4
3
module MLJBase
5
4
6
- export MLJType, Model, Supervised, Unsupervised, Deterministic, Probabilistic
5
+ export MLJType, Model, Supervised, Unsupervised
6
+ export Deterministic, Probabilistic, Interval
7
7
export DeterministicNetwork, ProbabilisticNetwork, UnsupervisedNetwork
8
8
export fit, update, clean!
9
9
export predict, predict_mean, predict_mode, fitted_params
10
10
export transform, inverse_transform, se, evaluate, best
11
- export load_path, package_url, package_name, package_uuid
12
- export input_scitype, supports_weights
13
- export target_scitype, output_scitype
14
- export is_pure_julia, is_wrapper
11
+ export info, info_dict
15
12
13
+ export load_path, package_url, package_name, package_uuid # model_traits.jl
14
+ export input_scitype, supports_weights # model_traits.jl
15
+ export target_scitype, output_scitype # model_traits.jl
16
+ export is_pure_julia, is_wrapper, prediction_type # model_traits.jl
16
17
export params # parameters.jl
17
18
export reconstruct, int, decoder, classes # data.jl
18
19
export selectrows, selectcols, select, nrows # data.jl
@@ -25,6 +26,14 @@ export UnivariateFinite, average # distributions.jl
25
26
export SupervisedTask, UnsupervisedTask, MLJTask # tasks.jl
26
27
export X_and_y, X_, y_, nrows, nfeatures # tasks.jl
27
28
export info # info.jl
29
+ export @load_boston , @load_ames , @load_iris # datasets.jl
30
+ export @load_reduced_ames # datasets.jl
31
+ export @load_crabs # datasets.jl
32
+ export orientation, reports_each_observation # measures.jl
33
+ export is_feature_dependent # measures.jl
34
+ export default_measure, value # measures.jl
35
+ export mav, mae, rms, rmsl, rmslp1, rmsp, l1, l2 # measures.jl
36
+ export misclassification_rate, cross_entropy # measures.jl
28
37
29
38
# methods from other packages to be rexported:
30
39
export pdf, mean, mode
@@ -36,6 +45,10 @@ export OrderedFactor, Multiclass, Count, Continuous
36
45
export Binary, ColorImage, GrayImage, Image
37
46
export scitype, scitype_union, coerce, schema
38
47
48
+ # rexport from Random, Statistics, Distributions, CategoricalArrays:
49
+ export pdf, mode, median, mean, shuffle!, categorical, shuffle, levels, levels!
50
+ export std
51
+
39
52
import Base.==
40
53
41
54
using Tables
@@ -90,6 +103,9 @@ abstract type Probabilistic <: Supervised end
90
103
# supervised models that `predict` point-values are of:
91
104
abstract type Deterministic <: Supervised end
92
105
106
+ # supervised models that `predict` intervals:
107
+ abstract type Interval <: Supervised end
108
+
93
109
# for models that are "exported" learning networks (return a Node as
94
110
# their fit-result; see MLJ docs:
95
111
abstract type ProbabilisticNetwork <: Probabilistic end
@@ -125,39 +141,6 @@ function inverse_transform end
125
141
# fitted parameters (eg, coeficients of linear model):
126
142
fitted_params (:: Model , fitresult) = (fitresult= fitresult,)
127
143
128
- # operations implemented by some meta-models:
129
- function se end
130
- function evaluate end
131
- function best end
132
-
133
- # a model wishing invalid hyperparameters to be corrected with a
134
- # warning should overload this method (return value is the warning
135
- # message):
136
- clean! (model:: Model ) = " "
137
-
138
- # fallback trait declarations:
139
- input_scitype (:: Any ) = Unknown
140
- output_scitype (:: Any ) = Unknown
141
- target_scitype (:: Any ) = Unknown
142
- is_pure_julia (:: Any ) = false
143
- package_name (:: Any ) = " unknown"
144
- package_license (:: Any ) = " unknown"
145
- load_path (:: Any ) = " unknown"
146
- package_uuid (:: Any ) = " unknown"
147
- package_url (:: Any ) = " unknown"
148
- is_wrapper (:: Any ) = false
149
- supports_weights (:: Any ) = false
150
-
151
- input_scitype (model:: Model ) = input_scitype (typeof (model))
152
- output_scitype (model:: Model ) = output_scitype (typeof (model))
153
- target_scitype (model:: Model ) = target_scitype (typeof (model))
154
- is_pure_julia (model:: Model ) = is_pure_julia (typeof (model))
155
- package_name (model:: Model ) = package_name (typeof (model))
156
- load_path (model:: Model ) = load_path (typeof (model))
157
- package_uuid (model:: Model ) = package_uuid (typeof (model))
158
- package_url (model:: Model ) = package_url (typeof (model))
159
- is_wrapper (m:: Model ) = is_wrapper (typeof (m))
160
-
161
144
# probabilistic supervised models may also overload one or more of
162
145
# `predict_mode`, `predict_median` and `predict_mean` defined below.
163
146
@@ -173,6 +156,31 @@ predict_mean(model::Probabilistic, fitresult, Xnew) =
173
156
predict_median (model:: Probabilistic , fitresult, Xnew) =
174
157
median .(predict (model, fitresult, Xnew))
175
158
159
+ # operations implemented by some meta-models:
160
+ function se end
161
+ function evaluate end
162
+ function best end
163
+
164
+ # a model wishing invalid hyperparameters to be corrected with a
165
+ # warning should overload this method (return value is the warning
166
+ # message):
167
+ clean! (model:: Model ) = " "
168
+
169
+
170
+ # # TRAITS
171
+
172
+ """
173
+
174
+ info(object)
175
+
176
+ List the traits of an object, such as a model or a performance measure.
177
+
178
+ """
179
+ info (object) = info (object, Val (ScientificTypes. trait (object)))
180
+
181
+
182
+ include (" model_traits.jl" )
183
+
176
184
# for unpacking the fields of MLJ objects:
177
185
include (" parameters.jl" )
178
186
@@ -187,7 +195,9 @@ include("data.jl")
187
195
include (" distributions.jl" )
188
196
189
197
include (" info.jl" )
198
+ include (" datasets.jl" ) # importing CSV will also load datasets_requires.jl
190
199
include (" tasks.jl" )
200
+ include (" measures.jl" )
191
201
192
202
# __init__() function:
193
203
include (" init.jl" )
0 commit comments