File tree Expand file tree Collapse file tree 3 files changed +23
-3
lines changed Expand file tree Collapse file tree 3 files changed +23
-3
lines changed Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ ScientificTypes = "3.0"
26
26
StatsBase = " 0.34"
27
27
TableOperations = " 1.2"
28
28
Tables = " 1.11"
29
- julia = " 1.6 "
29
+ julia = " 1.10 "
30
30
31
31
[extras ]
32
32
DataFrames = " a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ logic?"
16
16
- X: A table where the elements of the categorical features have [scitypes](https://juliaai.github.io/ScientificTypes.jl/dev/)
17
17
`Multiclass` or `OrderedFactor`
18
18
- features=[]: A list of names of categorical features given as symbols to exclude or include from encoding,
19
- according to the value of `ignore`
19
+ according to the value of `ignore`, or a single symbol (which is treated as a vector with one symbol),
20
20
or a callable that returns true for features to be included/excluded
21
21
- ignore=true: Whether to exclude or includes the features given in features
22
22
- ordered_factor=false: Whether to encode OrderedFactor or ignore them
@@ -40,8 +40,12 @@ function generic_fit(X,
40
40
feat_names = Tables. schema (X). names
41
41
42
42
# 2. Modify column_names based on features
43
+ if features isa Symbol
44
+ features = [features]
45
+ end
46
+
43
47
if features isa AbstractVector{Symbol}
44
- # Original behavior for vector of symbols
48
+ # Original behavior for vector of symbols
45
49
feat_names =
46
50
(ignore) ? setdiff (feat_names, features) : intersect (feat_names, features)
47
51
else
Original file line number Diff line number Diff line change 182
182
# Test 3: predicate with ordered_factor=true picks up ordered factors (e.g., :E)
183
183
cache3 = dummy_encoder_fit (X, predicate; ignore= false , ordered_factor= true )
184
184
@test Set (cache3[:encoded ]) == Set ([:A , :C , :E ])
185
+ end
186
+
187
+ @testset " Single Symbol and list of one symbol equivalence" begin
188
+ X = dataset_forms[1 ]
189
+ feat_names = Tables. schema (X). names
190
+
191
+ # Test 1: Single Symbol
192
+ single_symbol = :A
193
+ cache1 = dummy_encoder_fit (X, single_symbol; ignore= true , ordered_factor= false )
194
+ @test ! (:A in cache1[:encoded ])
195
+ # Test 2: List of one symbol
196
+ single_symbol_list = [:A ]
197
+ cache2 = dummy_encoder_fit (X, single_symbol_list; ignore= true , ordered_factor= false )
198
+ @test ! (:A in cache2[:encoded ])
199
+ # Test 3: Both should yield the same result
200
+ @test cache1[:encoded ] == cache2[:encoded ]
185
201
end
You can’t perform that action at this time.
0 commit comments