Skip to content

Commit 51b0946

Browse files
committed
dump MLJModelInterface references in tests
1 parent 8f81a92 commit 51b0946

File tree

8 files changed

+20
-22
lines changed

8 files changed

+20
-22
lines changed

test/encoders/contrast_encoder.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ end
358358
encoder = ContrastEncoder(ignore = true, ordered_factor = false)
359359
mach = machine(encoder, X)
360360
fit!(mach)
361-
Xnew_transf = MMI.transform(mach, X)
361+
Xnew_transf = MLJBase.transform(mach, X)
362362

363363
# same output
364364
@test X_transf == Xnew_transf
@@ -392,7 +392,7 @@ end
392392
buildmatrix = matrix_func[i],
393393
)
394394
mach = fit!(machine(encoder, X))
395-
Xnew = MMI.transform(mach, X)
395+
Xnew = MLJBase.transform(mach, X)
396396

397397
# Test Consistency with Types
398398
scs = schema(Xnew).scitypes

test/encoders/frequency_encoder.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ using MLJTransforms: frequency_encoder_fit, frequency_encoder_transform
55

66
X = dataset_forms[1]
77
normalize = [false, true]
8-
A_col, C_col, D_col, F_col = MMI.selectcols(X, [1, 3, 4, 6])
8+
A_col, C_col, D_col, F_col = selectcols(X, [1, 3, 4, 6])
99
for norm in normalize
1010
result = frequency_encoder_fit(X; normalize = norm)[:statistic_given_feat_val]
1111
enc =
@@ -72,7 +72,7 @@ end
7272
encoder = FrequencyEncoder(ignore = true, ordered_factor = false)
7373
mach = machine(encoder, X)
7474
fit!(mach)
75-
Xnew_transf = MMI.transform(mach, X)
75+
Xnew_transf = MLJBase.transform(mach, X)
7676

7777
# same output
7878
@test X_transf == Xnew_transf
@@ -111,7 +111,7 @@ end
111111

112112
encoder = FrequencyEncoder(ordered_factor = false, normalize = false)
113113
mach = fit!(machine(encoder, X))
114-
Xnew = MMI.transform(mach, X)
114+
Xnew = MLJBase.transform(mach, X)
115115

116116

117117
scs = schema(Xnew).scitypes

test/encoders/missingness_encoding.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ end
170170
encoder = MissingnessEncoder(ignore = true, ordered_factor = false)
171171
mach = machine(encoder, X)
172172
fit!(mach)
173-
Xnew_transf = MMI.transform(mach, X)
173+
Xnew_transf = MLJBase.transform(mach, X)
174174

175175
# same output
176176
@test isequal(X_transf, Xnew_transf)
@@ -197,7 +197,7 @@ end
197197

198198
encoder = MissingnessEncoder()
199199
mach = fit!(machine(encoder, Xm))
200-
Xnew = MMI.transform(mach, Xm)
200+
Xnew = MLJBase.transform(mach, Xm)
201201

202202
schema(Xm)
203203
schema(Xnew)

test/encoders/ordinal_encoding.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ push!(
1515
@test ordinal_encoder_fit(dataset_forms[1]) == ordinal_encoder_fit(dataset_forms[2])
1616
X = dataset_forms[1]
1717
result = ordinal_encoder_fit(X)[:index_given_feat_level]
18-
A_col, C_col, D_col, F_col = MMI.selectcols(X, [1, 3, 4, 6])
18+
A_col, C_col, D_col, F_col = selectcols(X, [1, 3, 4, 6])
1919
true_output = Dict{Symbol, Dict{Any, AbstractFloat}}(
2020
:F => Dict(
2121
"m" => findfirst(==("m"), levels(F_col)),
@@ -70,7 +70,7 @@ end
7070
encoder = OrdinalEncoder(ignore = true, ordered_factor = false)
7171
mach = machine(encoder, X)
7272
fit!(mach)
73-
Xnew_transf = MMI.transform(mach, X)
73+
Xnew_transf = MLJBase.transform(mach, X)
7474

7575
# same output
7676
@test X_transf == Xnew_transf
@@ -108,7 +108,7 @@ end
108108

109109
encoder = OrdinalEncoder(ordered_factor = false)
110110
mach = fit!(machine(encoder, X))
111-
Xnew = MMI.transform(mach, X)
111+
Xnew = MLJBase.transform(mach, X)
112112

113113
scs = schema(Xnew).scitypes
114114
ts = schema(Xnew).types
@@ -123,7 +123,7 @@ end
123123
## Int32 case
124124
encoder = OrdinalEncoder(ordered_factor = false, output_type = Int32)
125125
mach = fit!(machine(encoder, X))
126-
Xnew = MMI.transform(mach, X)
126+
Xnew = MLJBase.transform(mach, X)
127127
scs = schema(Xnew).scitypes
128128
ts = schema(Xnew).types
129129
# Check scitypes for previously categorical features

test/encoders/target_encoding.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ end
6363
X, y = classification_forms[1]
6464
n = length(y)
6565

66-
A_col, C_col, D_col, F_col = MMI.selectcols(X, [1, 3, 4, 6])
66+
A_col, C_col, D_col, F_col = selectcols(X, [1, 3, 4, 6])
6767
true_output = Dict{Symbol, Dict{Any, AbstractFloat}}(
6868
:F => Dict(
6969
"m" => sum(y[F_col.=="m"] .== 0) / length(y[F_col.=="m"]),
@@ -119,7 +119,7 @@ end
119119
n = length(y)
120120
μ̂ = mean(y)
121121

122-
A_col, C_col, D_col, F_col = MMI.selectcols(X, [1, 3, 4, 6])
122+
A_col, C_col, D_col, F_col = selectcols(X, [1, 3, 4, 6])
123123
true_output = Dict{Symbol, Dict{Any, AbstractFloat}}(
124124
:F => Dict(
125125
"m" => mean(y[F_col.=="m"]),
@@ -172,7 +172,7 @@ end
172172
y_classes = classes(y)
173173
n = length(y)
174174

175-
A_col, C_col, D_col, F_col = MMI.selectcols(X, [1, 3, 4, 6])
175+
A_col, C_col, D_col, F_col = selectcols(X, [1, 3, 4, 6])
176176
true_output = Dict{Symbol, Dict{Any, AbstractVector{AbstractFloat}}}(
177177
:F => Dict(
178178
"m" =>
@@ -320,7 +320,7 @@ end
320320
TargetEncoder(ignore = true, ordered_factor = false, lambda = 0.5, m = 1.0)
321321
mach = machine(encoder, X, y)
322322
fit!(mach)
323-
Xnew_transf = MMI.transform(mach, X)
323+
Xnew_transf = MLJBase.transform(mach, X)
324324

325325
# same output
326326
@test X_transf == Xnew_transf
@@ -386,7 +386,7 @@ end
386386

387387
encoder = TargetEncoder(ordered_factor = false, lambda = 1.0, m = 0)
388388
mach = fit!(machine(encoder, X, y))
389-
Xnew = MMI.transform(mach, X)
389+
Xnew = MLJBase.transform(mach, X)
390390

391391
scs = schema(Xnew).scitypes
392392
ts = schema(Xnew).types

test/generic.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ end
142142

143143
@testset "Test generic fit output" begin
144144
X = dataset_forms[1]
145-
A_col, C_col, D_col, F_col = MMI.selectcols(X, [1, 3, 4, 6])
145+
A_col, C_col, D_col, F_col = selectcols(X, [1, 3, 4, 6])
146146
result = dummy_encoder_fit(X)[:hash_given_feat_val]
147147
enc = (col, level) -> (hash(level))
148148
true_output = Dict{Symbol, Dict{Any, Any}}(

test/runtests.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ using StatsBase
77
using LinearAlgebra
88
import StatsModels
99
using Random
10-
import MLJModelInterface
11-
const MMI = MLJModelInterface
1210
using LinearAlgebra
1311

1412
# Other transformers

test/transformers/cardinality_reducer.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ end
208208
encoder = CardinalityReducer(min_frequency = 0.1, ignore = true, ordered_factor = false)
209209
mach = machine(encoder, X)
210210
fit!(mach)
211-
Xnew_transf = MMI.transform(mach, X)
211+
Xnew_transf = MLJBase.transform(mach, X)
212212

213213
# same output
214214
@test X_transf == Xnew_transf
@@ -240,11 +240,11 @@ end
240240

241241
encoder = CardinalityReducer(ordered_factor = false, min_frequency = 3)
242242
mach = fit!(machine(encoder, X))
243-
Xnew = MMI.transform(mach, X)
243+
Xnew = MLJBase.transform(mach, X)
244244
@test schema(X).types == schema(Xnew).types
245245
@test all(s -> (s <: Multiclass), schema(Xnew).scitypes)
246246
end
247247

248248

249249
# Look into MLJModelInterfaceTest
250-
# Add tests to ensure categorical feature properties are as expected
250+
# Add tests to ensure categorical feature properties are as expected

0 commit comments

Comments
 (0)