Skip to content

Commit f5f9183

Browse files
authored
Merge pull request #126 from JuliaAI/notraits
modify vtrait internal method
2 parents 5684782 + 5b2ea33 commit f5f9183

16 files changed

+836
-603
lines changed

src/MLJModelInterface.jl

Lines changed: 44 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module MLJModelInterface
22

3-
const MODEL_TRAITS =
4-
[:input_scitype,
3+
const MODEL_TRAITS = [
4+
:input_scitype,
55
:output_scitype,
66
:target_scitype,
77
:fit_data_scitype,
@@ -29,25 +29,27 @@ const MODEL_TRAITS =
2929
:hyperparameter_ranges,
3030
:iteration_parameter,
3131
:supports_training_losses,
32-
:deep_properties]
33-
34-
const ABSTRACT_MODEL_SUBTYPES =
35-
[:Supervised,
36-
:Unsupervised,
37-
:Probabilistic,
38-
:Deterministic,
39-
:Interval,
40-
:JointProbabilistic,
41-
:Static,
42-
:Annotator,
43-
:SupervisedAnnotator,
44-
:UnsupervisedAnnotator,
45-
:SupervisedDetector,
46-
:UnsupervisedDetector,
47-
:ProbabilisticSupervisedDetector,
48-
:ProbabilisticUnsupervisedDetector,
49-
:DeterministicSupervisedDetector,
50-
:DeterministicUnsupervisedDetector]
32+
:deep_properties
33+
]
34+
35+
const ABSTRACT_MODEL_SUBTYPES = [
36+
:Supervised,
37+
:Unsupervised,
38+
:Probabilistic,
39+
:Deterministic,
40+
:Interval,
41+
:JointProbabilistic,
42+
:Static,
43+
:Annotator,
44+
:SupervisedAnnotator,
45+
:UnsupervisedAnnotator,
46+
:SupervisedDetector,
47+
:UnsupervisedDetector,
48+
:ProbabilisticSupervisedDetector,
49+
:ProbabilisticUnsupervisedDetector,
50+
:DeterministicSupervisedDetector,
51+
:DeterministicUnsupervisedDetector
52+
]
5153

5254

5355
# ------------------------------------------------------------------------
@@ -56,6 +58,8 @@ using ScientificTypesBase
5658
using StatisticalTraits
5759
using Random
5860

61+
import StatisticalTraits: info
62+
5963
# ------------------------------------------------------------------------
6064
# exports
6165

@@ -64,6 +68,7 @@ export LightInterface, FullInterface
6468

6569
# model types
6670
export MLJType, Model
71+
6772
for T in ABSTRACT_MODEL_SUBTYPES
6873
@eval(export $T)
6974
end
@@ -89,29 +94,29 @@ end
8994

9095
# data operations
9196
export matrix, int, classes, decoder, table,
92-
nrows, selectrows, selectcols, select
97+
nrows, selectrows, selectcols, select, info
9398

9499
# equality
95100
export is_same_except, isrepresented
96101

97102
# re-exports from ScientificTypesBase
98103
export Scientific, Found, Unknown, Known, Finite, Infinite,
99-
OrderedFactor, Multiclass, Count, Continuous, Textual,
100-
Binary, ColorImage, GrayImage, Image, Table
101-
export scitype, scitype_union, elscitype, nonmissing, trait, info
104+
OrderedFactor, Multiclass, Count, Continuous, Textual,
105+
Binary, ColorImage, GrayImage, Image, Table, nonmissing
102106

103107
# ------------------------------------------------------------------------
104108
# To be extended
105109

106110
import Base.==
107111
import Base: in, isequal
108-
#
112+
109113
# ------------------------------------------------------------------------
110114
# Mode trick
111115

112-
abstract type Mode end
113-
struct LightInterface <: Mode end
114-
struct FullInterface <: Mode end
116+
struct LightInterface end
117+
struct FullInterface end
118+
119+
const Mode = Union{LightInterface, FullInterface}
115120

116121
const INTERFACE_MODE = Ref{Mode}(LightInterface())
117122

@@ -124,33 +129,33 @@ struct InterfaceError <: Exception
124129
end
125130

126131
abstract type MLJType end
127-
abstract type Model <: MLJType end
132+
abstract type Model <: MLJType end
128133

129134
# ------------------------------------------------------------------------
130135
# Model subtypes
131136

132-
abstract type Supervised <: Model end
133-
abstract type Unsupervised <: Model end
134-
abstract type Annotator <: Model end
137+
abstract type Supervised <: Model end
138+
abstract type Unsupervised <: Model end
139+
abstract type Annotator <: Model end
135140

136141
abstract type Probabilistic <: Supervised end
137142
abstract type Deterministic <: Supervised end
138-
abstract type Interval <: Supervised end
143+
abstract type Interval <: Supervised end
139144

140145
abstract type JointProbabilistic <: Probabilistic end
141146

142-
abstract type Static <: Unsupervised end
147+
abstract type Static <: Unsupervised end
143148

144-
abstract type SupervisedAnnotator <: Annotator end
149+
abstract type SupervisedAnnotator <: Annotator end
145150
abstract type UnsupervisedAnnotator <: Annotator end
146151

147152
abstract type UnsupervisedDetector <: UnsupervisedAnnotator end
148-
abstract type SupervisedDetector <: SupervisedAnnotator end
153+
abstract type SupervisedDetector <: SupervisedAnnotator end
149154

150-
abstract type ProbabilisticSupervisedDetector <: SupervisedDetector end
155+
abstract type ProbabilisticSupervisedDetector <: SupervisedDetector end
151156
abstract type ProbabilisticUnsupervisedDetector <: UnsupervisedDetector end
152157

153-
abstract type DeterministicSupervisedDetector <: SupervisedDetector end
158+
abstract type DeterministicSupervisedDetector <: SupervisedDetector end
154159
abstract type DeterministicUnsupervisedDetector <: UnsupervisedDetector end
155160

156161
# ------------------------------------------------------------------------
@@ -164,5 +169,4 @@ include("model_def.jl")
164169
include("model_api.jl")
165170
include("equality.jl")
166171

167-
168172
end # module

0 commit comments

Comments
 (0)