La til funksjon for utregning av RMSE
This commit is contained in:
parent
792f67f5f9
commit
7e3cd680ee
2 changed files with 20 additions and 0 deletions
|
|
@ -30,6 +30,7 @@ export TRLooCVUpdateNaive
|
||||||
export TRLooCVUpdateExperimental
|
export TRLooCVUpdateExperimental
|
||||||
|
|
||||||
# From "variousRegressionFunctions.jl"
|
# From "variousRegressionFunctions.jl"
|
||||||
|
export calculateRMSE
|
||||||
export oldRegCoeffs
|
export oldRegCoeffs
|
||||||
export PCR
|
export PCR
|
||||||
export PLS
|
export PLS
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,22 @@
|
||||||
|
"""
|
||||||
|
function rmse, ypred = calculateRMSE(X, y, beta)
|
||||||
|
|
||||||
|
Regner ut RMSE for lineær regresjonsmodell med eller uten konstantledd.
|
||||||
|
(Konstantledd må være første element i beta hvis med)
|
||||||
|
"""
|
||||||
|
|
||||||
|
function calculateRMSE(X, y, beta)
|
||||||
|
|
||||||
|
if length(beta) == size(X,2)
|
||||||
|
ypred = X * beta;
|
||||||
|
elseif length(beta) == (size(X,2) + 1)
|
||||||
|
ypred = beta[1] .+ X * beta[2:end]
|
||||||
|
end
|
||||||
|
|
||||||
|
rmsep = sqrt(mean(y - ypred).^2)
|
||||||
|
|
||||||
|
return rmse, ypred
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue