Input for ModelApplier
Strauss
New Altair Community Member
I work with Rapid Miner using the Java-API. I created a Model which I would like to use now. Is there a possibility to use the value of a Java variable as input for my model?
Tagged:
0
Answers
-
Hello
I am afraid I got you wrong, but...
If you look in the javadoc, you will see that every class that implements the interface "Model" provides a method calledExampleSet apply(ExampleSet testSet)
This method (normally) adds prediction and confidence attributes to the input ExampleSet testSet based on the used model.
throws OperatorException
Is this what you are looking for ?
Steffen
0 -
I don't know if this is what I'm lokking for...
I try to explain my problem:
I've got a time serie of values (for time=0,...,t ) which I used to generate a regression model. Now I want to apply an simple Integer value (t+1) to "forcast" the next value. But until now, I didn't find a way to apply this value which is saved in an integer variable to my model.
I really hopy someone know what I have to do. It is the first time I am using Rapid Miner...0 -
Hello,
first of all: welcome here to our community. I would like to give you two remarks:
1.) Although you probably do not want to hear this but: it is most often not a good idea to simply use a regression model for time series forecasting. The reasons is that the future predictions are not backed up by any of the seen data and therefore the predictions often tend to drop to zero. So what you probably want to use is a windowing approach together with a base regression learner. You can have a look into the discussion here
http://rapid-i.com/rapidforum/index.php/topic,16.0.html
in order to get the basic ideas.
2.) If you stick to the approach described in the link above, you can simply build a new window from the historical data plus the new one and apply the model to it just in the same way as you can apply a model to other data. The prediction of this model then is the prediction for the time lag defined by the horizon in the windowing approach.
Hope that gives you some hints how to work on your problem.
Cheers,
Ingo
0 -
Thank you very much for your advices. But it is part of my diploma thesis (where I evaluate the use of prediction methods for tuning an database system) using regression methods to predict values. I know that there are problems using the hole time serie to forecast something.
My approach is the following:
- monitoring performance metrics of an IT-system
- create a regression model using the last x snapshots (where x is a constant!!!)
- apply this model for the next time value to forecast the next performance value
If I am not wrong, I implicitly use the same idea like your explained window operator. In the meantime, I found another way to set my input parameters by using the database where all my values are saved.
But now, I have another problem: How can I access the predicted value to use it in my java program??? ???
I really hope that someone can explain it to me...0 -
Hi,
Using regression methods is perfectly fine. But you should consider to wrap the regression learning step into a windowing in order to get true predictions...
But it is part of my diploma thesis (where I evaluate the use of prediction methods for tuning an database system) using regression methods to predict values.
...what you seem to have
If I am not wrong, I implicitly use the same idea like your explained window operator. In the meantime, I found another way to set my input parameters by using the database where all my values are saved.
I should definitely read the full text before answering. You are right, your approach follows the basic windowing idea mentioned in the post above - but you have to perform more work manually in creating the data sets.
May I ask if you could post the source code you tried so far (for model building and model application)? I could give you some hints on the code then and add the missing lines for the retrieval of the model predictions.
But now, I have another problem: How can I access the predicted value to use it in my java program???
Cheers,
Ingo0 -
Hello,
It isn't so. All my data is stored in a database so that I can get the last x value using the FETCH-command in the sql-query. So I think it isn' t too much work.but you have to perform more work manually in creating the data sets.
My source code is the following:
I omitted the settings of the parameters because I think there aren't so relevant. In the meantime I found a way to get the predicted value, but I am sure there are better possibilities to get it:
// Model generation
Operator input = OperatorService.createOperator( DatabaseExampleSource.class );
/* ... */
process.getRootOperator().addOperator( input );
Operator putput = OperatorService.createOperator( LinearRegression.class );
process.getRootOperator().addOperator( putput );
Operator output = OperatorService.createOperator( ModelWriter.class );
/* ... */
process.getRootOperator().addOperator( output );
process.run();
// Applying data on model
Operator input = OperatorService.createOperator( ModelLoader.class );
/* ... */
process.getRootOperator().addOperator( input );
Operator input2 = OperatorService.createOperator( DatabaseExampleSource.class );
/* ... */
process.getRootOperator().addOperator( input2 );
Operator applier = OperatorService.createOperator( ModelApplier.class );
process.getRootOperator().addOperator( applier );
ExampleSet resultSet = process.run();
It would be great if you could show me a better way to the predicted value...
Example reader = resultSet.getExample(0);
Attributes att = reader.getAttributes();
String value = reader.getValueAsString( att.getPredictedLabel() );
result = Math.round( Float.parseFloat( value ) * 1000.0 )/1000.0;0 -
Hi again,
Looks good for me so far.
I omitted the settings of the parameters because I think there aren't so relevant. In the meantime I found a way to get the predicted value, but I am sure there are better possibilities to get it:
The one you mentioned is correct in principle. I just did not understand the last two lines. Why didn't you just use "getValue(Attribute)" as in the following snippet:
It would be great if you could show me a better way to the predicted value...
Cheers,
double result = reader.getValue(att.getPredictedLabel());
Ingo0 -
Thank you very much. I didn't consider the getValue(..) method. I changed my source code using it. ;D0