khkwong / Normalize.jl

MIT License
0 stars 0 forks source link

Add top-level transform function #6

Open tk3369 opened 3 years ago

tk3369 commented 3 years ago

Add a new transform function that runs all available methods (boxcox, yeojohnson, etc) and goodness test and return the best one.

The API may look like this:

function transform(xs; kwargs...)
end

I think it's best to return an object that includes the transformed data & chisq result from all transformers.

"""
Transformation result for a single method - BoxCox, YeoJohnson, etc.
"""
struct TransformResult{T <: Real}
    values::T
    chisq::Float64
end

struct TransformationSummary{T <: Real}
  results::Dict{NormalizeMethod, TransformationResult{T}}
end

Hence, transform function should return a TransformationSummary object. Then, we would have a function defined against TransformationSummary to pick the best one.

# Returns an array of values picked from the transformation results
function best_normalized(ts::TransformationSummary)
end

For now, let's just pass the keyword arguments along to all underlying transformers (BoxCox, YeoJohnson, etc.) For example, BoxCox takes α and scaled, and YeoJohnson takes any arguments that is accepted by Optim.optimize function. The caveat is that we may have collision of argument names across all transformers but let's not worry about that at this point.