Hello Everyone:
I am using Lathe:preprocess
Have attempted to activate the
following functions from HERE:
begin
mutable struct OneHotEncoder{P} <: Lathe.preprocess.Encoder
predict::P
function OneHotEncoder()
predict(df::DataFrame, symb::Symbol) = _onehot(df, symb)
P = typeof(predict)
return new{P}(predict)
end
end
end
No function return message, but no error
Then,
begin
function _onehot(df,symb)
copy = df
for c in unique(copy[!,symb])
copy[!,Symbol(c)] = copy[!,symb] .== c
end
return(copy)
end
end
Returning ‘_onehot (generic function with 1 method)’
I am encountering an error when I attempt to implement:
Lathe.preprocess.OneHotEncoder(CoDMW, "HeadShots")
Lathe.preprocess.OneHotEncoder(CodMW, "Injuries")
Lathe.preprocess.OneHotEncoder(CodMW, "SharedHits")
But I am encountering the following error:
MethodError: no method matching Lathe.preprocess.OneHotEncoder(::DataFrames.DataFrame, ::String)
When I replace the method with _onehot I get
new columns with the categorical values as
the column names, and the row values as Bool
types.
Is there a reason why the first function is not recognized?
Thank you.