Making Predictions on Using a Trained J48 Model

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Making Predictions on Using a Trained J48 Model

sachiz
Hello,

I hope someone can help me. I am using Weka version 3.8 to train a J48
classifier and test it on unseen data.
I am using the Weka Explorer GUI.

I split my dataset to separate training and testing ARFF files. Last column
of each row is the class label.
I trained the J48 model with no filters, 10-fold cross validation and saved
the model.

To make predictions on 'unseen' test data I loaded the trained model into
the Weka Explorer and provided the test data ARFF as "supplied test set" in
Test Options. I also set the class as *No Class*.
When I selected "Reevaluate Model on Current Test Set" option, I got the
following error

------------------------------------------------------
Data used to train model and test set are not compatible. Would you like to
automatically wrap the classifier in an"input mapped classifier" before
proceeding
------------------------------------------------------
For this I selected "No". Then I got the following error

--------------------------------------------------------------
Problem evaluating classifier: Train and test sets are not compatible Class
index differ 12 != 0
----------------------------------------------------------------

I do not understand why this error occurs. I checked the train and test file
headers and they seem to be identical.
If I selected the attribute "class" instead of "No Class" in supplied test
set, I do not get this error. But I am not sure that is the right way to
make predictions. What am I missing here?

I am also attaching the train and test arff files here.

behavior_features_full_train.arff
<https://weka.8497.n7.nabble.com/file/t7203/behavior_features_full_train.arff>  
behavior_features_full_test.arff
<https://weka.8497.n7.nabble.com/file/t7203/behavior_features_full_test.arff>  

Thank you very much for your time.
Sachini



--
Sent from: https://weka.8497.n7.nabble.com/
_______________________________________________
Wekalist mailing list -- [hidden email]
Send posts to [hidden email]
To unsubscribe send an email to [hidden email]
To subscribe, unsubscribe, etc., visit https://list.waikato.ac.nz/postorius/lists/wekalist.list.waikato.ac.nz
List etiquette: http://www.cs.waikato.ac.nz/~ml/weka/mailinglist_etiquette.html
Reply | Threaded
Open this post in threaded view
|

Re: Making Predictions on Using a Trained J48 Model

Peter Reutemann
> I hope someone can help me. I am using Weka version 3.8 to train a J48
> classifier and test it on unseen data.
> I am using the Weka Explorer GUI.
>
> I split my dataset to separate training and testing ARFF files. Last column
> of each row is the class label.
> I trained the J48 model with no filters, 10-fold cross validation and saved
> the model.
>
> To make predictions on 'unseen' test data I loaded the trained model into
> the Weka Explorer and provided the test data ARFF as "supplied test set" in
> Test Options. I also set the class as *No Class*.
> When I selected "Reevaluate Model on Current Test Set" option, I got the
> following error
>
> ------------------------------------------------------
> Data used to train model and test set are not compatible. Would you like to
> automatically wrap the classifier in an"input mapped classifier" before
> proceeding
> ------------------------------------------------------
> For this I selected "No". Then I got the following error
>
> --------------------------------------------------------------
> Problem evaluating classifier: Train and test sets are not compatible Class
> index differ 12 != 0
> ----------------------------------------------------------------
>
> I do not understand why this error occurs. I checked the train and test file
> headers and they seem to be identical.
> If I selected the attribute "class" instead of "No Class" in supplied test
> set, I do not get this error. But I am not sure that is the right way to
> make predictions. What am I missing here?
>
> I am also attaching the train and test arff files here.
>
> behavior_features_full_train.arff
> <https://weka.8497.n7.nabble.com/file/t7203/behavior_features_full_train.arff>
> behavior_features_full_test.arff
> <https://weka.8497.n7.nabble.com/file/t7203/behavior_features_full_test.arff>

The class attribute has to be set. If you really want to be sure that
the current class values aren't getting used replace them with missing
values.
Either use a text editor to replace all class values with a question
mark or you can use the MissingValuesInjection filter in conjunction
with the ClassOnly injection scheme from the following Weka package:
https://github.com/fracpete/missing-values-imputation-weka-package

Cheers, Peter
--
Peter Reutemann
Dept. of Computer Science
University of Waikato, NZ
+64 (7) 858-5174
http://www.cms.waikato.ac.nz/~fracpete/
http://www.data-mining.co.nz/
_______________________________________________
Wekalist mailing list -- [hidden email]
Send posts to [hidden email]
To unsubscribe send an email to [hidden email]
To subscribe, unsubscribe, etc., visit https://list.waikato.ac.nz/postorius/lists/wekalist.list.waikato.ac.nz
List etiquette: http://www.cs.waikato.ac.nz/~ml/weka/mailinglist_etiquette.html
Reply | Threaded
Open this post in threaded view
|

Re: Making Predictions on Using a Trained J48 Model

sachiz
Thank you Peter!
When you said "... either use a text editor to replace all class values with
a question mark ", did you mean it like what I have already done in the
attached > behavior_features_full_test.arff file?

I referred to quite a few tutorials and other documents online. They all
said that the Test Option need to be set to No Class, when making
predictions.
Thanks again for the very helpful clarification.



--
Sent from: https://weka.8497.n7.nabble.com/
_______________________________________________
Wekalist mailing list -- [hidden email]
Send posts to [hidden email]
To unsubscribe send an email to [hidden email]
To subscribe, unsubscribe, etc., visit https://list.waikato.ac.nz/postorius/lists/wekalist.list.waikato.ac.nz
List etiquette: http://www.cs.waikato.ac.nz/~ml/weka/mailinglist_etiquette.html
Reply | Threaded
Open this post in threaded view
|

Re: Making Predictions on Using a Trained J48 Model

Peter Reutemann
> When you said "... either use a text editor to replace all class values with
> a question mark ", did you mean it like what I have already done in the
> attached > behavior_features_full_test.arff file?

Yes, that's correct. Sorry, I didn't look at the ARFF file.

> I referred to quite a few tutorials and other documents online. They all
> said that the Test Option need to be set to No Class, when making
> predictions.

Are you sure they said "no class" rather than "missing class"? Because
that would be incorrect.

Cheers, Peter
--
Peter Reutemann
Dept. of Computer Science
University of Waikato, NZ
+64 (7) 858-5174
http://www.cms.waikato.ac.nz/~fracpete/
http://www.data-mining.co.nz/
_______________________________________________
Wekalist mailing list -- [hidden email]
Send posts to [hidden email]
To unsubscribe send an email to [hidden email]
To subscribe, unsubscribe, etc., visit https://list.waikato.ac.nz/postorius/lists/wekalist.list.waikato.ac.nz
List etiquette: http://www.cs.waikato.ac.nz/~ml/weka/mailinglist_etiquette.html