Repository /TunedIT/base/RegressionTT70.jar:org.tunedit.base.RegressionTT70


Back

No file description

Source code

/*
 *  Copyright (C) 2009 by TunedIT
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see http://www.gnu.org/licenses/.
 */
package org.tunedit.base;

import org.debellor.base.evaluator.TrainAndTest;
import org.debellor.core.Cell;
import org.debellor.core.exception.cell.CellException;
import org.tunedit.core.EvaluationProcedure;
import org.tunedit.core.ResourceLoader;
import org.tunedit.core.ResourceName;
import org.tunedit.core.StandardLoader;
import org.tunedit.core.exception.AlgorithmErrorException;
import org.tunedit.core.exception.EvaluationSetupException;
import org.tunedit.core.exception.TunedTesterException;

/**
 * @author Marcin Wojnarski
 *
 */
public class RegressionTT70 extends EvaluationProcedure {

	public Double[] run(ResourceName algorithm, ResourceName dataset, ResourceLoader loader)
			throws TunedTesterException, EvaluationSetupException, AlgorithmErrorException
	{
		StandardLoader standardLoader = new StandardLoader(loader);
		Cell data = standardLoader.loadData(dataset);
		Cell learner = standardLoader.loadCell(algorithm);
		
		try {
			TrainAndTest tt = new TrainAndTest(learner);
			tt.set("score", "RMSE");
			tt.set("trainPercent", "70");
			tt.setSource(data);

			tt.learn();
			
			Double[] result = tt.result();
			return result;
		}
		catch (CellException e) {
			throw new AlgorithmErrorException(e);
		}
	}

}

Copyright © 2008-2011 by TunedIT
Design by luksite