You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm guessing that the example below failures because you assume the target is a categorical vector whose "raw" type is Bool. However, it could be any type (in this case it is String). The example does not error if I insert the following code immediately after the unpack line:
y =map(y) do η
η =="1"?true:falseend
The example:
using MLJFair, MLJ
import DataFrames
model =@pipeline ContinuousEncoder @load(EvoTreeClassifier)
# load Indian Liver Patient Dataset:
data = OpenML.load(1480) |> DataFrames.DataFrame ;
y, X =unpack(data, ==(:Class), name->true; rng=123);
y =coerce(y, Multiclass);
coerce!(X, :V2=> Multiclass, Count => Continuous);
schema(X)
# Notes:# - The target `y` is 1 for liver patients, 2 otherwise# - The attribute `V2` of `X` is gender
wrappedModel =ReweighingSamplingWrapper(model, grp=:V2)
julia>evaluate(wrappedModel,
X, y,
measures=MetricWrappers(
[true_positive, true_positive_rate]; grp=:V2))
ERROR: MethodError: Cannot `convert` an object of type String to an object of type Bool
Closest candidates are:convert(::Type{T}, ::T) where T<:Number at number.jl:6convert(::Type{T}, ::Number) where T<:Number at number.jl:7convert(::Type{T}, ::Ptr) where T<:Integer at pointer.jl:23...
Stacktrace:
[1] convert(::Type{Bool}, ::CategoricalArrays.CategoricalValue{String,UInt32}) at /Users/anthony/.julia/packages/CategoricalArrays/nd8kj/src/value.jl:68
[2] setindex!(::Array{Bool,1}, ::CategoricalArrays.CategoricalValue{String,UInt32}, ::Int64) at ./array.jl:782
[3] copyto! at ./abstractarray.jl:807 [inlined]
[4] copyto! at ./abstractarray.jl:799 [inlined]
[5] AbstractArray at ./array.jl:499 [inlined]
[6] convert at ./abstractarray.jl:16 [inlined]
[7] fair_tensor(::CategoricalArrays.CategoricalArray{String,1,UInt32,String,CategoricalArrays.CategoricalValue{String,UInt32},Union{}}, ::CategoricalArrays.CategoricalArray{String,1,UInt32,String,CategoricalArrays.CategoricalValue{String,UInt32},Union{}}, ::CategoricalArrays.CategoricalArray{String,1,UInt32,String,CategoricalArrays.CategoricalValue{String,UInt32},Union{}}) at /Users/anthony/Dropbox/Julia7/MLJ/MLJFair/src/fair_tensor.jl:54
[8] (::MetricWrapper)(::MLJBase.UnivariateFiniteArray{Multiclass{2},String,UInt32,Float32,1}, ::DataFrames.DataFrame, ::CategoricalArrays.CategoricalArray{String,1,UInt32,String,CategoricalArrays.CategoricalValue{String,UInt32},Union{}}) at /Users/anthony/Dropbox/Julia7/MLJ/MLJFair/src/measures/metricWrapper.jl:50
[9] value at /Users/anthony/.julia/packages/MLJBase/r3heT/src/measures/measures.jl:74 [inlined]
[10] value at /Users/anthony/.julia/packages/MLJBase/r3heT/src/measures/measures.jl:64 [inlined]
[11] (::MLJBase.var"#264#269"{DataFrames.DataFrame,CategoricalArrays.CategoricalArray{String,1,UInt32,String,CategoricalArrays.CategoricalValue{String,UInt32},Union{}},MLJBase.UnivariateFiniteArray{Multiclass{2},String,UInt32,Float32,1}})(::MetricWrapper) at ./none:0
[12] collect(::Base.Generator{Array{Any,1},MLJBase.var"#264#269"{DataFrames.DataFrame,CategoricalArrays.CategoricalArray{String,1,UInt32,String,CategoricalArrays.CategoricalValue{String,UInt32},Union{}},MLJBase.UnivariateFiniteArray{Multiclass{2},String,UInt32,Float32,1}}}) at ./generator.jl:47
[13] (::MLJBase.var"#get_measurements#268"{Array{Tuple{Array{Int64,1},Array{Int64,1}},1},Nothing,Int64,Array{Any,1},typeof(predict),Bool,DataFrames.DataFrame,CategoricalArrays.CategoricalArray{String,1,UInt32,String,CategoricalArrays.CategoricalValue{String,UInt32},Union{}}})(::Machine{ReweighingSamplingWrapper}, ::Int64) at /Users/anthony/.julia/packages/MLJBase/r3heT/src/resampling.jl:779
[14] #248 at /Users/anthony/.julia/packages/MLJBase/r3heT/src/resampling.jl:64 [inlined]
[15] _mapreduce(::MLJBase.var"#248#249"{MLJBase.var"#get_measurements#268"{Array{Tuple{Array{Int64,1},Array{Int64,1}},1},Nothing,Int64,Array{Any,1},typeof(predict),Bool,DataFrames.DataFrame,CategoricalArrays.CategoricalArray{String,1,UInt32,String,CategoricalArrays.CategoricalValue{String,UInt32},Union{}}},Machine{ReweighingSamplingWrapper},Int64,ProgressMeter.Progress}, ::typeof(vcat), ::IndexLinear, ::UnitRange{Int64}) at ./reduce.jl:309
[16] _mapreduce_dim at ./reducedim.jl:312 [inlined]
[17] #mapreduce#584 at ./reducedim.jl:307 [inlined]
[18] mapreduce at ./reducedim.jl:307 [inlined]
[19] _evaluate!(::MLJBase.var"#get_measurements#268"{Array{Tuple{Array{Int64,1},Array{Int64,1}},1},Nothing,Int64,Array{Any,1},typeof(predict),Bool,DataFrames.DataFrame,CategoricalArrays.CategoricalArray{String,1,UInt32,String,CategoricalArrays.CategoricalValue{String,UInt32},Union{}}}, ::Machine{ReweighingSamplingWrapper}, ::CPU1{Nothing}, ::Int64, ::Int64) at /Users/anthony/.julia/packages/MLJBase/r3heT/src/resampling.jl:643
[20] evaluate!(::Machine{ReweighingSamplingWrapper}, ::Array{Tuple{Array{Int64,1},Array{Int64,1}},1}, ::Nothing, ::Nothing, ::Int64, ::Int64, ::Array{Any,1}, ::typeof(predict), ::CPU1{Nothing}, ::Bool) at /Users/anthony/.julia/packages/MLJBase/r3heT/src/resampling.jl:796
[21] evaluate!(::Machine{ReweighingSamplingWrapper}, ::CV, ::Nothing, ::Nothing, ::Int64, ::Int64, ::Array{Any,1}, ::Function, ::CPU1{Nothing}, ::Bool) at /Users/anthony/.julia/packages/MLJBase/r3heT/src/resampling.jl:859
[22] #evaluate!#242(::CV, ::Array{Any,1}, ::Array{Any,1}, ::Nothing, ::Function, ::CPU1{Nothing}, ::Nothing, ::Int64, ::Bool, ::Bool, ::Int64, ::typeof(evaluate!), ::Machine{ReweighingSamplingWrapper}) at /Users/anthony/.julia/packages/MLJBase/r3heT/src/resampling.jl:608
[23] (::MLJBase.var"#kw##evaluate!")(::NamedTuple{(:measures,),Tuple{Array{Any,1}}}, ::typeof(evaluate!), ::Machine{ReweighingSamplingWrapper}) at ./none:0
[24] #evaluate#247(::Base.Iterators.Pairs{Symbol,Array{Any,1},Tuple{Symbol},NamedTuple{(:measures,),Tuple{Array{Any,1}}}}, ::typeof(evaluate), ::ReweighingSamplingWrapper, ::DataFrames.DataFrame, ::Vararg{Any,N} where N) at /Users/anthony/.julia/packages/MLJBase/r3heT/src/resampling.jl:626
[25] (::MLJModelInterface.var"#kw##evaluate")(::NamedTuple{(:measures,),Tuple{Array{Any,1}}}, ::typeof(evaluate), ::ReweighingSamplingWrapper, ::DataFrames.DataFrame, ::Vararg{Any,N}where N) at ./none:0
[26] top-level scope at REPL[89]:1
The text was updated successfully, but these errors were encountered:
I'm guessing that the example below failures because you assume the target is a categorical vector whose "raw" type is
Bool
. However, it could be any type (in this case it isString
). The example does not error if I insert the following code immediately after theunpack
line:The example:
The text was updated successfully, but these errors were encountered: