@@ -30,21 +30,14 @@ assertions(transform::OneHot) = [scitypeassert(Categorical, transform.selector)]
30
30
31
31
isrevertible (:: Type{<:OneHot} ) = true
32
32
33
- _categ (x) = categorical (x), identity
34
- function _categ (x:: CategoricalArray )
35
- l, o = levels (x), isordered (x)
36
- revfun = y -> categorical (y, levels= l, ordered= o)
37
- x, revfun
38
- end
39
-
40
33
function applyfeat (transform:: OneHot , feat, prep)
41
34
cols = Tables. columns (feat)
42
35
names = Tables. columnnames (cols) |> collect
43
36
columns = Any[Tables. getcolumn (cols, nm) for nm in names]
44
37
45
38
name = selectsingle (transform. selector, names)
46
39
ind = findfirst (== (name), names)
47
- x, revfun = _categ (columns[ind])
40
+ x, revfun = _categorical (columns[ind])
48
41
49
42
xlevels = levels (x)
50
43
onehot = map (xlevels) do l
@@ -89,3 +82,10 @@ function revertfeat(::OneHot, newfeat, fcache)
89
82
𝒯 = (; zip (names, columns)... )
90
83
𝒯 |> Tables. materializer (newfeat)
91
84
end
85
+
86
+ _categorical (x) = x, identity
87
+ function _categorical (x:: CategoricalArray )
88
+ l, o = levels (x), isordered (x)
89
+ revfun = y -> categorical (y, levels= l, ordered= o)
90
+ x, revfun
91
+ end
0 commit comments