java-ml-support Mailing List for Java Machine Learning Library
Status: Beta
Brought to you by:
thomasabeel
You can subscribe to this list here.
| 2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2011 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(2) |
| 2012 |
Jan
(1) |
Feb
|
Mar
(1) |
Apr
(1) |
May
|
Jun
(1) |
Jul
|
Aug
(3) |
Sep
|
Oct
|
Nov
(3) |
Dec
|
| 2013 |
Jan
(1) |
Feb
(1) |
Mar
(1) |
Apr
(3) |
May
|
Jun
(1) |
Jul
(2) |
Aug
(5) |
Sep
|
Oct
(1) |
Nov
(5) |
Dec
|
| 2014 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
(2) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2015 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(3) |
Oct
|
Nov
|
Dec
(1) |
| 2016 |
Jan
|
Feb
|
Mar
(2) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
| 2018 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
| 2019 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
|
| S | M | T | W | T | F | S |
|---|---|---|---|---|---|---|
|
|
|
|
|
1
|
2
|
3
|
|
4
|
5
|
6
|
7
|
8
|
9
|
10
|
|
11
(1) |
12
(2) |
13
|
14
|
15
|
16
|
17
|
|
18
|
19
|
20
|
21
|
22
|
23
|
24
|
|
25
|
26
|
27
|
28
|
29
|
30
|
|
|
From: Tom D. <tom...@gm...> - 2012-11-12 18:24:57
|
Thanks for the reply. The way in which I'm constructing training data is
the following:
private Dataset buildTrainingDataset(Object[][] data, int
sampleIntervalWidth, int futureDays) throws StorageException{
Log.logMessage(LogLevel.DEBUG,
"Engine.buildDataset(",data,sampleIntervalWidth,")");
// The data set we are building up.
Dataset ds = new DefaultDataset();
// Create all samples
for(int i = 0; i + sampleIntervalWidth <= data.length - futureDays;
i++){
// Add the sample domain data
DenseInstance di = new DenseInstance(buildSampleDoubleArr(data, i,
sampleIntervalWidth));
// Get the "current" and future price for this sample
double original =
Double.valueOf(data[i+sampleIntervalWidth-1][data[0].length-1].toString());
double future =
Double.valueOf(data[i+sampleIntervalWidth+futureDays-1][data[0].length-1].toString());
// Find the relative growth or decline
Double classification = (future - original) / original;
// Round the growth or decline to the nearest hundredth
classification = ((int) ((classification * 100.0)+0.5)) / 100.0;
// Convert to percentage
classification = classification * 100;
// Use the percentage growth
di.setClassValue(classification);
// Add the sample to the data set
ds.add(di);
}
return ds;
}
Summary: I am indeed setting a class value for each Instance in the
training Dataset, and the values are of type Double. Please let me know if
you need to see anything else.
Thanks,
Tom
On Mon, Nov 12, 2012 at 11:16 AM, Thomas Abeel <th...@ab...> wrote:
> Hi Tom,
>
> Did you set class labels in the method buildTrainingDataset?
>
> Training data needs class labels.
>
> You'll need to provide a fully contained working code sample to get more
> help. We can't help you if the two methods that create the objects that are
> responsible for the exception are not provided.
>
> cheers,
> Thomas
>
> On 11/11/2012 4:29 PM, Tom Deering wrote:
>
> I am new to Java-ML, so I apologize if the answer to this is trivial:
>
> I'm trying to construct and use a Classifier in the following way:
>
> // Construct an instance of the selected classifier
> Classifier c = constructClassifier(classifier); // This returns a
> NaiveBayesClassifier
> ...
> // Build a training Dataset for the symbol using the historical
> data
> Dataset trainingData = buildTrainingDataset(dataArr,
> sampleIntervalWidth, futureDays);
> ...
> // Train the classifier
> c.buildClassifier(trainingData); // NullPointerException happens
> here
> ...
> // Now, classify against the latest sample
> DenseInstance latestSample = new
> DenseInstance(buildSampleDoubleArr(dataArr, dataArr.length -
> sampleIntervalWidth - 1, sampleIntervalWidth));
> ...
> // Store the result
> results.put(s, (Double)c.classify(latestSample));
>
> Each time I try this, I seem to be getting a NullPointerException from
> the innards of AbstractBayesianClassifier with the following stack trace:
>
> Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
> at
> net.sf.javaml.classification.bayes.AbstractBayesianClassifier.calculateClassFreqs(AbstractBayesianClassifier.java:207)
> at
> net.sf.javaml.classification.bayes.AbstractBayesianClassifier.buildClassifier(AbstractBayesianClassifier.java:103)
> at
> net.sf.javaml.classification.bayes.NaiveBayesClassifier.buildClassifier(NaiveBayesClassifier.java:42)
> at tdeering.iastate.cs572.ainvestor.engine.Engine.rank(Engine.java:106)
>
> Can anyone tell me what I am doing wrong? Am I missing a step where I
> tell my Classfier about all possible classes?
>
> Thanks,
>
> Tom
>
>
> ------------------------------------------------------------------------------
> Everyone hates slow websites. So do we.
> Make your web apps faster with AppDynamics
> Download AppDynamics Lite for free today:http://p.sf.net/sfu/appdyn_d2d_nov
>
>
>
> _______________________________________________
> Java-ml-support mailing lis...@li...://lists.sourceforge.net/lists/listinfo/java-ml-support
>
>
>
|
|
From: Thomas A. <th...@ab...> - 2012-11-12 17:33:26
|
Hi Tom, Did you set class labels in the method buildTrainingDataset? Training data needs class labels. You'll need to provide a fully contained working code sample to get more help. We can't help you if the two methods that create the objects that are responsible for the exception are not provided. cheers, Thomas On 11/11/2012 4:29 PM, Tom Deering wrote: > I am new to Java-ML, so I apologize if the answer to this is trivial: > > I'm trying to construct and use a Classifier in the following way: > > // Construct an instance of the selected classifier > Classifier c = constructClassifier(classifier); // This > returns a NaiveBayesClassifier > ... > // Build a training Dataset for the symbol using the > historical data > Dataset trainingData = buildTrainingDataset(dataArr, > sampleIntervalWidth, futureDays); > ... > // Train the classifier > c.buildClassifier(trainingData); // NullPointerException happens here > ... > // Now, classify against the latest sample > DenseInstance latestSample = new > DenseInstance(buildSampleDoubleArr(dataArr, dataArr.length - > sampleIntervalWidth - 1, sampleIntervalWidth)); > ... > // Store the result > results.put(s, (Double)c.classify(latestSample)); > > Each time I try this, I seem to be getting a NullPointerException from > the innards of AbstractBayesianClassifier with the following stack trace: > > Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException > at > net.sf.javaml.classification.bayes.AbstractBayesianClassifier.calculateClassFreqs(AbstractBayesianClassifier.java:207) > at > net.sf.javaml.classification.bayes.AbstractBayesianClassifier.buildClassifier(AbstractBayesianClassifier.java:103) > at > net.sf.javaml.classification.bayes.NaiveBayesClassifier.buildClassifier(NaiveBayesClassifier.java:42) > at tdeering.iastate.cs572.ainvestor.engine.Engine.rank(Engine.java:106) > > Can anyone tell me what I am doing wrong? Am I missing a step where I > tell my Classfier about all possible classes? > > Thanks, > > Tom > > > ------------------------------------------------------------------------------ > Everyone hates slow websites. So do we. > Make your web apps faster with AppDynamics > Download AppDynamics Lite for free today: > http://p.sf.net/sfu/appdyn_d2d_nov > > > _______________________________________________ > Java-ml-support mailing list > Jav...@li... > https://lists.sourceforge.net/lists/listinfo/java-ml-support |
|
From: Tom D. <tom...@gm...> - 2012-11-11 21:29:55
|
I am new to Java-ML, so I apologize if the answer to this is trivial:
I'm trying to construct and use a Classifier in the following way:
// Construct an instance of the selected classifier
Classifier c = constructClassifier(classifier); // This returns a
NaiveBayesClassifier
...
// Build a training Dataset for the symbol using the historical data
Dataset trainingData = buildTrainingDataset(dataArr,
sampleIntervalWidth, futureDays);
...
// Train the classifier
c.buildClassifier(trainingData); // NullPointerException happens
here
...
// Now, classify against the latest sample
DenseInstance latestSample = new
DenseInstance(buildSampleDoubleArr(dataArr, dataArr.length -
sampleIntervalWidth - 1, sampleIntervalWidth));
...
// Store the result
results.put(s, (Double)c.classify(latestSample));
Each time I try this, I seem to be getting a NullPointerException from the
innards of AbstractBayesianClassifier with the following stack trace:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at
net.sf.javaml.classification.bayes.AbstractBayesianClassifier.calculateClassFreqs(AbstractBayesianClassifier.java:207)
at
net.sf.javaml.classification.bayes.AbstractBayesianClassifier.buildClassifier(AbstractBayesianClassifier.java:103)
at
net.sf.javaml.classification.bayes.NaiveBayesClassifier.buildClassifier(NaiveBayesClassifier.java:42)
at tdeering.iastate.cs572.ainvestor.engine.Engine.rank(Engine.java:106)
Can anyone tell me what I am doing wrong? Am I missing a step where I tell
my Classfier about all possible classes?
Thanks,
Tom
|