Open
Description
Like https://scikit-learn.org/stable/modules/generated/sklearn.model_selection.cross_val_predict.html (pointed out by @josephsdavid!)
Currently, I am doing it manually, which works fine:
X = DataFrame(df.features)
y = df.label
stratified_cv = StratifiedCV(; nfolds=6,
shuffle=true,
rng=StableRNG(123))
tt_pairs = MLJBase.train_test_pairs(stratified_cv, 1:nrow(X), y)
cv = []
predictions = DataFrame()
for (train_indices, test_indices) in tt_pairs
model = ...
mach = machine(model, X[train_indices, :], y[train_indices])
MLJ.fit!(mach)
push!(cv, (; machine=mach, train_indices, test_indices))
ŷ = MLJ.predict(mach, X[test_indices, :])
append!(predictions, hcat(df[test_indices, :], DataFrame(:prediction => ŷ)))
end
It would be nice if evaluate
could give the predictions as well, since it needs to generate them anyway.
Metadata
Metadata
Assignees
Labels
No labels