Custom XGBoost Loss function w/ Zygote. Julia Computing blog post

Perhaps this is what you want. I’m using SVC with RBF kernel having two parameters (C and gamma) to optimize. Just replace the @distributed code that uses parallelism above.

ftable = @distributed (vcat) for C in 1:5
    gres = @distributed (vcat) for gamma = 1:5
        svcmodel  = SKLearner("SVC",Dict(:impl_args=>Dict(:kernel=>"rbf",:C=>C,:gamma=>gamma) ))
        mn,sd,fld,err = crossvalidate(svcmodel,X,Y)
        DataFrame(name=svcmodel.name,mean=mn,sd=sd,C=C,gamma=gamma,folds=fld,errors=err)
    end
    gres
end
dfsorted=sort(ftable,:mean,rev=true)
@show dfsorted
25×7 DataFrame
│ Row │ name    │ mean     │ sd        │ C     │ gamma │ folds │ errors │
│     │ String  │ Float64  │ Float64   │ Int64 │ Int64 │ Int64 │ Int64  │
├─────┼─────────┼──────────┼───────────┼───────┼───────┼───────┼────────┤
│ 1   │ SVC_G24 │ 0.966667 │ 0.0471405 │ 1     │ 1     │ 10    │ 0      │
│ 2   │ SVC_E9A │ 0.966667 │ 0.0471405 │ 3     │ 1     │ 10    │ 0      │
│ 3   │ SVC_3xr │ 0.96     │ 0.0466137 │ 1     │ 2     │ 10    │ 0      │
│ 4   │ SVC_wcn │ 0.96     │ 0.0466137 │ 2     │ 1     │ 10    │ 0      │
│ 5   │ SVC_RxN │ 0.96     │ 0.0466137 │ 4     │ 2     │ 10    │ 0      │
│ 6   │ SVC_Oor │ 0.96     │ 0.0466137 │ 2     │ 3     │ 10    │ 0      │
│ 7   │ SVC_ATA │ 0.96     │ 0.0344265 │ 3     │ 4     │ 10    │ 0      │
│ 8   │ SVC_NRs │ 0.96     │ 0.0466137 │ 3     │ 5     │ 10    │ 0      │
│ 9   │ SVC_CoV │ 0.953333 │ 0.0449966 │ 1     │ 4     │ 10    │ 0      │
⋮
│ 16  │ SVC_n99 │ 0.953333 │ 0.0706233 │ 1     │ 3     │ 10    │ 0      │
│ 17  │ SVC_Ux0 │ 0.953333 │ 0.0449966 │ 3     │ 2     │ 10    │ 0      │
│ 18  │ SVC_O6M │ 0.953333 │ 0.0706233 │ 4     │ 1     │ 10    │ 0      │
│ 19  │ SVC_otD │ 0.953333 │ 0.0322031 │ 4     │ 4     │ 10    │ 0      │
│ 20  │ SVC_iIi │ 0.953333 │ 0.0322031 │ 5     │ 1     │ 10    │ 0      │
│ 21  │ SVC_XjT │ 0.953333 │ 0.0632456 │ 5     │ 2     │ 10    │ 0      │
│ 22  │ SVC_zEv │ 0.946667 │ 0.068853  │ 5     │ 5     │ 10    │ 0      │
│ 23  │ SVC_ldK │ 0.946667 │ 0.0421637 │ 3     │ 3     │ 10    │ 0      │
│ 24  │ SVC_n0e │ 0.946667 │ 0.0525874 │ 4     │ 3     │ 10    │ 0      │
│ 25  │ SVC_diL │ 0.946667 │ 0.0525874 │ 5     │ 3     │ 10    │ 0      │
2 Likes