All Downloads are FREE. Search and download functionalities are using the official Maven repository.

maths.functions.regularizers.ElasticNetRegularizer Maven / Gradle / Ivy

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;
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy