Hi Eibe,

Here's the code, thanks

private static void StockBotModel() throws Exception
{
String filePath = "C:\\Users\\Thorpe\\Documents\\StockDataWEKAFiltered.csv";
DataSource source = new DataSource(filePath);
Instances data = source.getDataSet();
data.setClassIndex(data.numAttributes() - 1);
Classifier cModel = (Classifier)new J48();
// Classifier cModel = (Classifier)new MultilayerPerceptron();
cModel.buildClassifier(data);
// String predictFilePath = "C:\\Users\\Thorpe\\Documents\\WekaUseData.csv";
source = new DataSource(filePath);
Instances useData = source.getDataSet();
useData.setClassIndex(useData.numAttributes() - 1);

int foundInstanceCount= 0;
for(int n=0;n<useData.numInstances();n++)
{
Instance iUse = useData.instance(n);
iUse.setDataset(data);
double[] fDistribution = cModel.distributionForInstance(iUse);
Attribute att = iUse.classAttribute();

int index = 0;
double max = 0;
for(int i=0;i<fDistribution.length;i++)
{
double dist = fDistribution[i];
if(dist > max) 
{
index = i;
max = dist;
}
}
String action = att.value(index);

if(action.compareToIgnoreCase("NoBuy") != 0)
{
foundInstanceCount++;
System.out.println(action);
}
}
System.out.println("Total Instances: " + useData.numInstances());
if(foundInstanceCount == 0)
System.out.println("No matches found");
else
System.out.println("Found count: " + foundInstanceCount);
}

On Tue, Mar 8, 2016 at 11:32 PM, Eibe Frank <eibe@waikato.ac.nz> wrote:
You need to call distributionForInstance() for every instance in the dataset you use for evaluation, and check whether the class that receives maximum probability is the correct class for that instance.

Maybe you should send the code you use to compute the percentage of correct classifications.

Cheers,
Eibe

> On 9 Mar 2016, at 10:29, Jerry Thorpe <jerryjthorpe@gmail.com> wrote:
>
> Hi Eibe,
>
> So should I be checking something besides the distribution? To be sure of my results I ran a training set using the buildClassifier (data) call then distributionForInstance to use the model. From what you are saying I must be doing something wrong. Do you know where their is some sample code that I can check out?
>
> Thanks,
> Jerry
>
> On Mar 8, 2016 12:42 PM, "Eibe Frank" <eibe@waikato.ac.nz> wrote:
> Yes, you should get the same result, regardless of whether you use the API or one of WEKA’s user interfaces, as long as the training and test sets are the same.
>
> Cheers,
> Eibe
>
> > On 9/03/2016, at 2:51 AM, Jerry Thorpe <jerryjthorpe@gmail.com> wrote:
> >
> > I am using J48 on a data set with 9,000 records. During the training I get a 75% correct rate but when i use the same data in my Java code the distribution rate only finds 120 out of the 9,000 which is about 1.3%.Shouldn't the values match since the data set is the same?
> >
> > Thanks
> > _______________________________________________
> > Wekalist mailing list
> > Send posts to: Wekalist@list.waikato.ac.nz
> > List info and subscription status: http://list.waikato.ac.nz/mailman/listinfo/wekalist
> > List etiquette: http://www.cs.waikato.ac.nz/~ml/weka/mailinglist_etiquette.html
>
> _______________________________________________
> Wekalist mailing list
> Send posts to: Wekalist@list.waikato.ac.nz
> List info and subscription status: http://list.waikato.ac.nz/mailman/listinfo/wekalist
> List etiquette: http://www.cs.waikato.ac.nz/~ml/weka/mailinglist_etiquette.html
> _______________________________________________
> Wekalist mailing list
> Send posts to: Wekalist@list.waikato.ac.nz
> List info and subscription status: http://list.waikato.ac.nz/mailman/listinfo/wekalist
> List etiquette: http://www.cs.waikato.ac.nz/~ml/weka/mailinglist_etiquette.html

_______________________________________________
Wekalist mailing list
Send posts to: Wekalist@list.waikato.ac.nz
List info and subscription status: http://list.waikato.ac.nz/mailman/listinfo/wekalist
List etiquette: http://www.cs.waikato.ac.nz/~ml/weka/mailinglist_etiquette.html