maths.functions.regularizers.ElasticNetRegularizer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jstat Show documentation
Show all versions of jstat Show documentation
Java Library for Statistical Analysis.
The newest version!
package maths.functions.regularizers;
import datastructs.IVector;
import maths.functions.IRegularizerFunction;
import maths.functions.IVectorRealFunction;
public class ElasticNetRegularizer implements IRegularizerFunction {
/**
* Constructor.
*/
public ElasticNetRegularizer(double lambda1, double lambda2, int startCoeffs, IVectorRealFunction> hypothesis){
this.startCoeffs = startCoeffs;
this.lambda1 = lambda1;
this.lambda2 = lambda2;
this.hypothesis = hypothesis;
}
/**
* Returns the value of the regularizer
*/
@Override
public Double evaluate(Void input){
IVector coeffs = hypothesis.getCoeffs();
if(coeffs == null){
throw new IllegalStateException("Hypothesis coefficients are null");
}
double sum1 = 0.0;
double sum2 = 0.0;
for(int c=startCoeffs; c> hypothesis;
}