Example usage for org.apache.mahout.classifier.sgd ElasticBandPrior ElasticBandPrior

List of usage examples for org.apache.mahout.classifier.sgd ElasticBandPrior ElasticBandPrior

Introduction

In this page you can find the example usage for org.apache.mahout.classifier.sgd ElasticBandPrior ElasticBandPrior.

Prototype

public ElasticBandPrior() 

Source Link

Usage

From source file:org.deidentifier.arx.aggregates.classification.MultiClassLogisticRegression.java

License:Apache License

/**
 * Creates a new instance/*www  . ja  v a  2 s .c  o  m*/
 * @param specification
 * @param config
 */
public MultiClassLogisticRegression(ClassificationDataSpecification specification,
        ARXLogisticRegressionConfiguration config) {

    // Store
    this.config = config;
    this.specification = specification;

    // Prepare classifier
    PriorFunction prior = null;
    switch (config.getPriorFunction()) {
    case ELASTIC_BAND:
        prior = new ElasticBandPrior();
        break;
    case L1:
        prior = new L1();
        break;
    case L2:
        prior = new L2();
        break;
    case UNIFORM:
        prior = new UniformPrior();
        break;
    default:
        throw new IllegalArgumentException("Unknown prior function");
    }
    this.lr = new OnlineLogisticRegression(this.specification.classMap.size(), config.getVectorLength(), prior);

    // Configure
    this.lr.learningRate(config.getLearningRate());
    this.lr.alpha(config.getAlpha());
    this.lr.lambda(config.getLambda());
    this.lr.stepOffset(config.getStepOffset());
    this.lr.decayExponent(config.getDecayExponent());

    // Prepare encoders
    this.interceptEncoder = new ConstantValueEncoder("intercept");
    this.wordEncoder = new StaticWordValueEncoder("feature");

    // Configure
    this.lr.learningRate(1);
    this.lr.alpha(1);
    this.lr.lambda(0.000001);
    this.lr.stepOffset(10000);
    this.lr.decayExponent(0.2);
}