1
1
module StatisticalTraits
2
2
3
3
using ScientificTypes
4
-
4
+ import Base . instances
5
5
6
6
# # CONSTANTS
7
7
@@ -26,7 +26,13 @@ const TRAITS = [
26
26
:prediction_type ,
27
27
:hyperparameters ,
28
28
:hyperparameter_types ,
29
- :hyperparameter_ranges ]
29
+ :hyperparameter_ranges ,
30
+ :orientation ,
31
+ :reports_each_observation ,
32
+ :aggregation ,
33
+ :is_feature_dependent ,
34
+ :distribution_type
35
+ ]
30
36
31
37
32
38
# # EXPORT
@@ -35,9 +41,23 @@ for trait in TRAITS
35
41
eval (:(export $ trait))
36
42
end
37
43
44
+ export Mean, Sum, RootMeanSquare
45
+
46
+
47
+ # # TYPES
48
+
49
+ # For the possible values of the `aggregation` trait:
50
+ abstract type AggregationMode end
51
+ struct Sum <: AggregationMode end
52
+ struct Mean <: AggregationMode end
53
+ struct RootMeanSquare <: AggregationMode end
54
+
38
55
39
56
# # HELPERS
40
57
58
+ # Some helper functions are needed to construct sensible fallbacks for
59
+ # some traits.
60
+
41
61
"""
42
62
43
63
typename(T::Type)
@@ -55,7 +75,7 @@ function typename(M)
55
75
if isdefined (M, :name )
56
76
return M. name. name
57
77
elseif isdefined (M, :body )
58
- return _typename (M. body)
78
+ return typename (M. body)
59
79
else
60
80
return Symbol (string (M))
61
81
end
95
115
snakecase (s:: Symbol ) = Symbol (snakecase (string (s)))
96
116
97
117
98
-
99
118
# # TRAITS
100
119
101
120
# The following can return any scientific type, that is, any type
@@ -131,12 +150,16 @@ prediction_type(::Type) = :unknown # used for measures too
131
150
132
151
# Miscellaneous:
133
152
134
- is_wrapper (:: Type ) = false # or `true`
135
- supports_online (:: Type ) = false # or `true`
136
- docstring (M:: Type ) = string (M) # some `String`
137
- is_supervised (:: Type ) = false # or `true`
138
- human_name (M:: Type ) = snakecase (name (M), delim= ' ' ) # `name` defined below
139
-
153
+ is_wrapper (:: Type ) = false # or `true`
154
+ supports_online (:: Type ) = false # or `true`
155
+ docstring (M:: Type ) = string (M) # some `String`
156
+ is_supervised (:: Type ) = false # or `true`
157
+ human_name (M:: Type ) = snakecase (name (M), delim= ' ' ) # `name` defined below
158
+ orientation (:: Type ) = :loss # or `:score`, `:other`
159
+ aggregation (:: Type ) = Mean ()
160
+ is_feature_dependent (:: Type ) = false
161
+ reports_each_observation (:: Type ) = false
162
+ distribution_type (:: Type ) = missing
140
163
141
164
# Returns a tuple, with one entry per field of `T` (the type of some
142
165
# statistical model, for example). Each entry is `nothing` or defines
@@ -162,7 +185,8 @@ for trait in TRAITS
162
185
eval (ex)
163
186
end
164
187
165
- # # INFO METHOD FOR QUERYING TRAITS
188
+
189
+ # # INFO STUB FOR QUERYING TRAITS
166
190
167
191
"""
168
192
info(X)
@@ -180,4 +204,3 @@ info(X) = info(X, Val(ScientificTypes.trait(X)))
180
204
info (X, :: Val{:other} ) = NamedTuple ()
181
205
182
206
end # module
183
-
0 commit comments