kaz-Anova / StackNet

StackNet is a computational, scalable and analytical Meta modelling framework
MIT License
1.32k stars 344 forks source link

predict with StackNet #18

Closed ajing closed 7 years ago

ajing commented 7 years ago

When I was trying to predict on a new file with the trained model. I specified the model directory by "model=models". However, StackNet failed to load models. Does that mean I need to rerun StackNet with the new pred_file?

kaz-Anova commented 7 years ago

What name did you provide for the model when you did the train? You need to provide exactly the same for predict. Can you see that file saved? Did StackNet provide you with an error during training ? Something in the form of model failed to export

In any case, there are certain algorithms that wont be serialised properly (all the H2O ones) and I am still trying to fix that issue so if you can see the model file you specified inside the set location but you still got an error at predict, is likely to be because you used one of these algos.

To answer your question , if indeed there is an error when the model was exported I am afraid you will have to rerun.

I strongly advice you though to provide a test and a pred_file file during train task to ensure the prediction will definitely happen. errors are likely to happen only during predict , if train runs properly.

(This untll I fix some exportation errors)

ajing commented 7 years ago

You are right. I did not provide the model when I did the train. I will definitely do that..

Because the prediction file is large, I got out of memory error. So, I tried to predict using the existing model to save some time. I used many lightgbm models, not sure whether that can be serialized properly. The program didn't provide any error about the model failed to export.

Here is the error I got when I try the 'predict' option:

parameter name : test_target value :  false
parameter name : verbose value :  true
parameter name : threads value :  10
parameter name : folds value :  5
parameter name : seed value :  1
parameter name : metric value :  mae
parameter name : output_name value :  restack
parameter name : folds value :  10
parameter name : seed value :  1
parameter name : task value :  regression
Exception in thread "main" java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
Caused by: java.lang.ClassCastException: ml.stacknet.StackNetRegressor cannot be cast to ml.stacknet.StackNetClassifier
        at stacknetrun.runstacknet.main(runstacknet.java:775)
        ... 5 more