"How to specify/load/force a linear regression model?"
anthill
New Altair Community Member
Hi there, great product, really enjoying learning how to use RapidMiner.
For my first project, I'm trying to assess an existing model (made several years ago) with a new dataset, and see how its performance is holding up.
However I can't figure out how to load a linear regression model! I can export models generated in RapidMiner to .MOD / XML files and re-load them, but how do I manually enter coefficients and intercepts? I tried kludging my own .XML file by hand, but RapidMiner won't load it.
For my first project, I'm trying to assess an existing model (made several years ago) with a new dataset, and see how its performance is holding up.
However I can't figure out how to load a linear regression model! I can export models generated in RapidMiner to .MOD / XML files and re-load them, but how do I manually enter coefficients and intercepts? I tried kludging my own .XML file by hand, but RapidMiner won't load it.
Tagged:
0
Answers
-
Hi,
actually you can't do this right now. The only way to create your own linear regression model would be to use the script operator. Here's an example process that should show you the trick:<?xml version="1.0" encoding="UTF-8" standalone="no"?>
Greetings,
<process version="5.0">
<context>
<input/>
<output/>
<macros/>
</context>
<operator activated="true" class="process" compatibility="5.0.10" expanded="true" name="Process">
<process expanded="true" height="314" width="748">
<operator activated="true" class="generate_data" compatibility="5.0.8" expanded="true" height="60" name="Generate Data" width="90" x="45" y="30"/>
<operator activated="true" class="multiply" compatibility="5.0.8" expanded="true" height="94" name="Multiply" width="90" x="179" y="30"/>
<operator activated="true" class="execute_script" compatibility="5.0.8" expanded="true" height="76" name="Execute Script" width="90" x="380" y="30">
<parameter key="script" value="import com.rapidminer.operator.learner.functions.LinearRegressionModel;		 ExampleSet exampleSet = input[0]; 		int numberOfAttributes = exampleSet.getAttributes().size(); 		boolean[] attributeSelection = new boolean[numberOfAttributes]; 		Arrays.fill(attributeSelection, true); 		// data just used for information. If not available could be left zero 		double[] standardErrors = new double[numberOfAttributes]; 		double[] standardizedCoefficients = new double[numberOfAttributes]; 		double[] tStatistics = new double[numberOfAttributes]; 		double[] pValues = new double[numberOfAttributes]; 		 		// data for calculating results 		double[] coefficients = new double[numberOfAttributes + 1]; 		// entering all coefficients you want to set > 0. Last coefficient is bias. 		coefficients[0] = 1; 		// bias 		coefficients[coefficients.length - 1] = 5; 		 		// class names might be null if regression task is performed 		String firstClassName = null; 		String secondClassName = null; 		 		return(new LinearRegressionModel(exampleSet, attributeSelection, coefficients, standardErrors, standardizedCoefficients, tStatistics, pValues, true, firstClassName, secondClassName));		 "/>
</operator>
<operator activated="true" class="apply_model" compatibility="5.0.8" expanded="true" height="76" name="Apply Model" width="90" x="447" y="165">
<list key="application_parameters"/>
</operator>
<connect from_op="Generate Data" from_port="output" to_op="Multiply" to_port="input"/>
<connect from_op="Multiply" from_port="output 1" to_op="Execute Script" to_port="input 1"/>
<connect from_op="Multiply" from_port="output 2" to_op="Apply Model" to_port="unlabelled data"/>
<connect from_op="Execute Script" from_port="output 1" to_op="Apply Model" to_port="model"/>
<connect from_op="Apply Model" from_port="labelled data" to_port="result 1"/>
<portSpacing port="source_input 1" spacing="0"/>
<portSpacing port="sink_result 1" spacing="0"/>
<portSpacing port="sink_result 2" spacing="0"/>
</process>
</operator>
</process>
Sebastian0