Integration with Weka

The RVErS algorithm for variable elimination runs in the context of the learning algorithm. I have applied RVErS to following learning algorithms in Weka:

I have written two new classes that build on top of these algorithms:

Cost Function for NaiveBayesRVErS

/**
* Function to compute M(L, n) for the algorithm based on the cost metric
* @param numAttributes number of input variables
* @return cost value
*/
private int costFunction(int numAttributes) {
int cost = (m_Instances.numClasses() * (numAttributes + 1)) * m_Instances.numInstances();
return cost;
}

Cost Function for J48RVErS

/**
* Function to compute M(L, n) for the algorithm based on the cost metric
* @param numAttributes number of input variables
* @return cost value
*/
private int costFunction(int numAttributes) {
int cost = ((int)measureTreeSize()) * numAttributes * m_Instances.numInstances();
return cost;
}


In NaiveBayesRVErS, I first create an instance of NaiveBayesRVErS then read the instances from the dataset. I use the weka function buildClassifier function of NaiveBayes weka class to build the hypothesis on training instances. I then evaluate the hypothesis using the function weka.classifiers.Evaluation.crossValidateModel with number of folds as 5. I measure the error in hypothesis using the function weka.classifiers.Evaluation.pctIncorrect

The procedure for J48RVErS is very similar to NaiveBayesRVErS with the only difference being that in J48RVErS I explicitly disable the tree pruning by calling the function weka.classifiers.trees.J48.setUnpruned with paramter 'true'.

The complete source code for NaiveBayesRVErS and J48RVErS can be accessed from here