Test one instance in weka that has no class label

This question has already been asked, but I did not understand the answer, so I am sending the question again, please answer.

I have a weka model, for example: j48 I prepared this model for my data set, and now I need to test the model with a single instance in which it should return the class label. How to do it?

I tried the following methods:

1) When I give my test instance a, b, c, class for a class like ?. It shows a problem with classifier rating. Test and test incompatible

2) When do I list all class labels and do I put them? for the class label for the test instance as follows:

@attribute class {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27} @data 1,2,............,? 

It does not show any results, such as

 === Evaluation on test set === === Summary === Total Number of Instances 0 Ignored Class Unknown Instances 1 === Detailed Accuracy By Class === TP Rate FP Rate Precision Recall F-Measure ROC Area Class 0 0 0 0 0 ? 1 0 0 0 0 0 ? 2 0 0 0 0 0 ? 3 Weighted Avg. NaN NaN NaN NaN NaN NaN 

confusion matrix is ​​null

What to do?

+4
source share
1 answer

Given the incomplete information from the OP, here is what probably happened:

You used

  • Weka GUI Chooser
  • chose Weka Explorer
  • uploaded your training data on the Preprocess tab
  • select the classify tab
  • chose the classifier J48
  • The supplied test suite was selected for the test parameters and provided the aforementioned test suite
  • click Start

Now you have a problem:

The “Test Set Evaluation” should have given it because you are evaluating a classifier — or better: a trained model. But for evaluation, you need to compare the predicted class with the actual class that you did not provide. Therefore, an instance with a missing class label will be ignored.

Since you do not have other test instances with a class label, the confusion matrix is ​​empty. There is simply not enough information to create it. (And just like a side note: the confusion matrix for just one instance looks useless.)

To see the actual prediction

You need to go to Advanced options ... , click Select next to Output forecasts and select an output format, for example. PlainText and you will see something like:

 inst# actual predicted error prediction 1 1:? 1:0 0.757 2 1:? 1:0 0.824 3 1:? 1:0 0.807 4 1:? 1:0 0.807 5 1:? 1:0 0.79 6 1:? 2:1 0.661 

This release lists the secret instances in the order they appear in the test file. This example was taken from Weka’s “Prediction” website with the following explanation.

In this case, taken directly from the test data set, where all attribute classes were marked with “?”, The “actual” column, which can be ignored, simply states that each class belongs to an unknown class. The “predicted” column shows that examples 1 through 5 are predicted to be class 1, whose value is 0, and example 6 is class 2, whose value is 1. The error field is empty; if the predictions were performed on a labeled set of tests, each case where the prediction did not match the label would contain a “+”. the probability that instance 1 actually belongs to class 0 is evaluated at 0.757.

+5
source

Source: https://habr.com/ru/post/1496878/


All Articles