private:atooltoclassifyeasily
Table of Contents
A tool to classify easily
Get the class of a given value for a known (min bound, max bound, classWidth)
You may use the ClassMaker this way:
// ClassesMaker (double vMin, double vMax, int nClasses) ClassesMaker cm = new ClassesMaker (1, 10, 2); double w = cm.getClassWidth (); int index = cm.whichClass (3.2); double center = cm.getClassCenter (index);
The main method of ClassesMaker contains a test:
ClassesMaker vMin 1.0 vMax 10.0 nClasses 5 EPSILON 1.0E-5 classWidth 1.8 classes limits 1 2.8 4.6 6.4 8.2 10 class (1) 0 class (1.2) 0 class (5) 2 class (9) 4 class (10) 5 ClassesMaker vMin 2.0 vMax 10.0 nClasses 2 EPSILON 1.0E-5 classWidth 4.0 classes limits 2 6 10 cm.getClassWidth () 4.0 cm.whichClass (6.1) 1 cm.getClassCenter (1) 8.0
Get a distribution from a list of objects and a known classification criterion
You may use the Classifier, itself based on the ClassMaker:
Collection list = new ArrayList (); list.add (new Double (0)); list.add (new Double (1.1)); list.add (new Double (2)); list.add (new Double (8.1)); list.add (new Double (8.2)); list.add (new Double (10)); // Which value must be used for the objects in the list (other e.g. ((Tree) o).getDbh ()) ClassifierCriterion cc = new ClassifierCriterion() { @Override public double getValue (Object o) { return ((Double) o).doubleValue (); } }; // min bound: 0, classWidth: 1 Classifier c = new Classifier (list, cc, 0, 1); int rc = c.execute (); System.out.println (c.toString ()); // Available methods: c.getDistribution (); c.getN (); c.getMinLabels (); c.getCenterLabels (); c.getMaxLabels (); //...
What the Classifier.toString () method returns in this case:
Classifier vMin: 0.0 vMax: 11.0 classWidth: 1.0 n: 11 0.5 [0,1[: 1 1.5 [1,2[: 1 2.5 [2,3[: 1 3.5 [3,4[: 0 4.5 [4,5[: 0 5.5 [5,6[: 0 6.5 [6,7[: 0 7.5 [7,8[: 0 8.5 [8,9[: 2 9.5 [9,10[: 0 10.5 [10,11[: 1
private/atooltoclassifyeasily.txt ยท Last modified: 2021/12/17 09:22 by 127.0.0.1