Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/transforms/stdfeats.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ isrevertible(::Type{StdFeats}) = true
_stdfun(x) = _stdfun(elscitype(x), x)
_stdfun(::Type, x) = identity, identity
function _stdfun(::Type{Continuous}, x)
μ = mean(x)
σ = std(x, mean=μ)
μ = mean(skipmissing(x))
σ = std(skipmissing(x), mean=μ)
stdfun = x -> zscore(x, μ, σ)
revfun = y -> revzscore(y, μ, σ)
stdfun, revfun
Expand Down
10 changes: 10 additions & 0 deletions test/transforms/stdfeats.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,14 @@
@test tₒ.c == t.c
@test tₒ.d ≈ t.d
@test tₒ.e == t.e

# missing values
a = [rand(1:10, 99); missing]
b = [rand(Normal(7, 10), 99); missing]
t = Table(; a, b)
T = StdFeats()
n, c = apply(T, t)
@test isequal(n.a, t.a)
@test isapprox(mean(skipmissing(n.b)), 0; atol=1e-6)
@test isapprox(std(skipmissing(n.b)), 1; atol=1e-6)
end
Loading