From f7350649bef146d121e7e58bfba07b4586bd36ff Mon Sep 17 00:00:00 2001 From: Joakim Skogholt Date: Thu, 11 May 2023 11:05:13 +0200 Subject: [PATCH] commit message --- Project.toml | 2 +- src/MinPakke.jl | 1 + src/convenience.jl | 18 ++++++++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index cfb61bb..2fd521d 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "MinPakke" uuid = "be803360-cecc-4859-8120-03d0223bb960" authors = ["Joakim"] -version = "1.0.1-DEV" +version = "1.0.2-DEV" [deps] LaTeXStrings = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f" diff --git a/src/MinPakke.jl b/src/MinPakke.jl index 66c81b7..86e2291 100644 --- a/src/MinPakke.jl +++ b/src/MinPakke.jl @@ -28,6 +28,7 @@ export createDataSplitBinaryStratified export importData export calculateRMSE export predRegression +export modelSelectionStatistics export PCR export bidiag2 diff --git a/src/convenience.jl b/src/convenience.jl index 3c9468c..178061b 100644 --- a/src/convenience.jl +++ b/src/convenience.jl @@ -16,8 +16,26 @@ XVal = my_split["XVal"]; using Random +""" + function modelSelectionStatistics(results) +Takes as input the rmse output from calculateRMSE and returns +the number of components minimising the validation error +together with the test set results. +""" +function modelSelectionStatistics(results) +n_iter = size(results, 3); +results_sel = zeros(n_iter); +n_comps = convert(Vector{Int64}, zeros(n_iter)); + +for i=1:n_iter + _, n_comps[i] = findmin(results[2,:,i]); + results_sel[i] = results[3, n_comps[i], i]; +end + +return results_sel, n_comps +end