@@ -0,0 +1,2447 @@
+package edu.neu.ccs.pyramid.application;%0A%0Aimport edu.neu.ccs.pyramid.configuration.Config;%0Aimport edu.neu.ccs.pyramid.dataset.DataSetType;%0Aimport edu.neu.ccs.pyramid.dataset.RegDataSet;%0Aimport edu.neu.ccs.pyramid.dataset.TRECFormat;%0Aimport edu.neu.ccs.pyramid.eval.RMSE;%0Aimport edu.neu.ccs.pyramid.regression.linear_regression.ElasticNetLinearRegOptimizer;%0Aimport edu.neu.ccs.pyramid.regression.linear_regression.LinearRegression;%0A%0A/**%0A * Linear Regression with Elasticnet (L1+L2) regularization%0A * Created by chengli on 2/25/16.%0A */%0Apublic class App4 %7B%0A%0A    public static void main(String%5B%5D args) throws Exception%7B%0A        if (args.length !=1)%7B%0A            throw new IllegalArgumentException(%22Please specify a properties file.%22);%0A        %7D%0A%0A        Config config = new Config(args%5B0%5D);%0A        System.out.println(config);%0A%0A        String sparsity = config.getString(%22featureMatrix.sparsity%22).toLowerCase();%0A        DataSetType dataSetType = null;%0A        switch (sparsity)%7B%0A            case %22dense%22:%0A                dataSetType = DataSetType.REG_DENSE;%0A                break;%0A            case %22sparse%22:%0A                dataSetType = DataSetType.REG_SPARSE;%0A                break;%0A            default:%0A                throw new IllegalArgumentException(%22featureMatrix.sparsity can be either dense or sparse%22);%0A        %7D%0A%0A        RegDataSet trainSet = TRECFormat.loadRegDataSet(config.getString(%22input.trainSet%22),dataSetType,true);%0A        RegDataSet testSet = TRECFormat.loadRegDataSet(config.getString(%22input.testSet%22),dataSetType,true);%0A%0A        LinearRegression linearRegression = new LinearRegression(trainSet.getNumFeatures());%0A        ElasticNetLinearRegOptimizer optimizer = new ElasticNetLinearRegOptimizer(linearRegression,trainSet);%0A        optimizer.setRegularization(config.getDouble(%22regularization%22));%0A        optimizer.setL1Ratio(config.getDouble(%22l1Ratio%22));%0A        System.out.println(%22before training%22);%0A        System.out.println(%22training set RMSE = %22+ RMSE.rmse(linearRegression,trainSet));%0A        System.out.println(%22test set RMSE = %22+ RMSE.rmse(linearRegression,testSet));%0A        System.out.println(%22start training%22);%0A        optimizer.optimize();%0A        System.out.println(%22training done%22);%0A        System.out.println(%22after training%22);%0A        System.out.println(%22training set RMSE = %22+ RMSE.rmse(linearRegression,trainSet));%0A        System.out.println(%22test set RMSE = %22+ RMSE.rmse(linearRegression,testSet));%0A    %7D%0A%7D%0A

add App4