Added EMSC
This commit is contained in:
parent
82740963ec
commit
6b1916b8cd
2 changed files with 23 additions and 0 deletions
|
|
@ -30,6 +30,8 @@ export TRLooCVUpdateNaive
|
||||||
export TRLooCVUpdateExperimental
|
export TRLooCVUpdateExperimental
|
||||||
|
|
||||||
# From "variousRegressionFunctions.jl"
|
# From "variousRegressionFunctions.jl"
|
||||||
|
export EMSC
|
||||||
|
export EMSCCorrection
|
||||||
export cVals
|
export cVals
|
||||||
export calculateRMSE
|
export calculateRMSE
|
||||||
export oldRegCoeffs
|
export oldRegCoeffs
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,24 @@
|
||||||
|
function EMSCCorrection(X, basis)
|
||||||
|
|
||||||
|
coeffs = basis \ X';
|
||||||
|
X_Cor = (X - coeffs[2:end,:]' * basis[:,2:end]') ./ coeffs[1,:];
|
||||||
|
|
||||||
|
return X_Cor
|
||||||
|
end
|
||||||
|
|
||||||
|
function EMSC(X, polDeg=2)
|
||||||
|
|
||||||
|
n, p = size(X);
|
||||||
|
P = zeros(p, polDeg+1);
|
||||||
|
[P[:,i] = LinRange(-1, 1, p).^(i-1) for i in 1:polDeg+1];
|
||||||
|
refSpec = mean(X, dims=1)';
|
||||||
|
basis = [refSpec P];
|
||||||
|
|
||||||
|
X_Cor = EMSCCorrection(X, basis);
|
||||||
|
|
||||||
|
return X_Cor, basis
|
||||||
|
end
|
||||||
|
|
||||||
"""
|
"""
|
||||||
crit1minInd, crit2minInd, CvalCrit1, CvalCrit2 = function cVals(bcoeffs, rmsecv)
|
crit1minInd, crit2minInd, CvalCrit1, CvalCrit2 = function cVals(bcoeffs, rmsecv)
|
||||||
Crit1 = 'norm(regcoeffs) + cverror'
|
Crit1 = 'norm(regcoeffs) + cverror'
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue