Pages: [1]
  Print  
Author Topic: Input for ModelApplier  (Read 2557 times)
Strauss
Newbie
*
Posts: 10


« on: July 16, 2008, 04:03:52 PM »

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?
Logged
steffen
Sr. Member
****
Posts: 376



« Reply #1 on: July 16, 2008, 05:34:34 PM »

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 called
Code:
ExampleSet apply(ExampleSet testSet)
                 throws OperatorException

This method (normally) adds prediction and confidence attributes to the input ExampleSet testSet based on the used model.

Is this what you are looking for ?

Steffen
« Last Edit: July 16, 2008, 07:23:25 PM by steffen » Logged

"I want to make computers do what I mean instead of what I say"
Read The Fantastic Manual
Strauss
Newbie
*
Posts: 10


« Reply #2 on: July 17, 2008, 04:08:15 PM »

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...
Logged
Ingo Mierswa
Administrator
Hero Member
*****
Posts: 1221



WWW
« Reply #3 on: July 18, 2008, 10:26:59 AM »

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

Logged

Did you try our new Marketplace? Upload or download new Extensions, add comments, and organize your operators. Have a look at  http://marketplace.rapid-i.com
Strauss
Newbie
*
Posts: 10


« Reply #4 on: July 19, 2008, 03:24:31 PM »

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???  Huh

I really hope that someone can explain it to me...
« Last Edit: July 20, 2008, 12:32:16 PM by Strauss » Logged
Ingo Mierswa
Administrator
Hero Member
*****
Posts: 1221



WWW
« Reply #5 on: July 22, 2008, 03:47:14 PM »

Hi,

Quote
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.

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...

Quote
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.

...what you seem to have  Wink

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.


Quote
But now, I have another problem: How can I access the predicted value to use it in my java program???

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.

Cheers,
Ingo
Logged

Did you try our new Marketplace? Upload or download new Extensions, add comments, and organize your operators. Have a look at  http://marketplace.rapid-i.com
Strauss
Newbie
*
Posts: 10


« Reply #6 on: July 22, 2008, 04:44:14 PM »

Hello,

Quote
but you have to perform more work manually in creating the data sets.

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.

My source code is the following:

Code:
// 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();

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:

Code:
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;

It would be great if you could show me a better way to the predicted value...
« Last Edit: July 22, 2008, 04:47:46 PM by Strauss » Logged
Ingo Mierswa
Administrator
Hero Member
*****
Posts: 1221



WWW
« Reply #7 on: July 22, 2008, 05:01:47 PM »

Hi again,

Quote
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:

Looks good for me so far.

Quote
It would be great if you could show me a better way to the predicted value...

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:

Code:
double result = reader.getValue(att.getPredictedLabel());

Cheers,
Ingo
Logged

Did you try our new Marketplace? Upload or download new Extensions, add comments, and organize your operators. Have a look at  http://marketplace.rapid-i.com
Strauss
Newbie
*
Posts: 10


« Reply #8 on: July 23, 2008, 07:19:58 AM »

Thank you very much. I didn't consider the getValue(..) method. I changed my source code using it.  Grin
Logged
Pages: [1]
  Print  
 
Jump to: