Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

divided by 0 #4

Closed
yuhang-lin opened this issue Aug 16, 2017 · 1 comment
Closed

divided by 0 #4

yuhang-lin opened this issue Aug 16, 2017 · 1 comment

Comments

@yuhang-lin
Copy link

Hi!

When I used your code, I found a potential bug of 0 divided by 0:

Exception in thread "main" java.lang.ArithmeticException: / by zero
at moa.clusterers.dstream.Dstream.trainOnInstanceImpl(Dstream.java:348)
at moa.clusterers.AbstractClusterer.trainOnInstance(AbstractClusterer.java:131)
at mytest.TestDStream.main(TestDStream.java:24)

My testing code is:

package mytest;

import com.yahoo.labs.samoa.instances.Instance;

import moa.cluster.Clustering;
import moa.clusterers.dstream.Dstream;
import moa.streams.clustering.ClusteringStream;
import moa.streams.clustering.FileStream;

public class TestDStream {

	public static void main(String[] args) {
		FileStream fStream = new FileStream();
		fStream.arffFileOption.setValue("test.arff");// set the ARFF file name
		fStream.normalizeOption.setValue(false);// set normalized to be true or false
		fStream.prepareForUse();
		int numLines = 0;
		//DStream
		Dstream dstream = new Dstream();
		dstream.resetLearning();
		ClusteringStream stream = fStream;
		while (stream.hasMoreInstances()) {
			Instance curr = stream.nextInstance().getData();
			dstream.trainOnInstance(curr);
			numLines++;
		}
		Clustering resDstream = dstream.getClusteringResult();
		dstream.getMicroClusteringResult();
		System.out.println("Size of result from Dstream: " + resDstream.size());
		System.out.println(numLines + " lines have been read");
	}
}

Thanks.

@richard-moulton
Copy link
Owner

This issue was also identified in the MOA Developers Google Group: https://groups.google.com/forum/#!topic/moa-development/3IKcguR2kOk

As mentioned there, the error uncovered occurred when the procedure to calculate gap produces a zero. This has been modified so that gap cannot be set to zero: if the procedure produces a zero, gap will instead be set to one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants