size() public method

public size ( ) : int
return int
Ejemplo n.º 1
0
        //
        // PRIVATE METHODS
        //

        private DecisionTree decisionTreeLearning(DataSet ds,
                List<String> attributeNames, ConstantDecisonTree defaultTree)
        {
            if (ds.size() == 0)
            {
                return defaultTree;
            }
            if (allExamplesHaveSameClassification(ds))
            {
                return new ConstantDecisonTree(ds.getExample(0).targetValue());
            }
            if (attributeNames.Count == 0)
            {
                return majorityValue(ds);
            }
            String chosenAttribute = chooseAttribute(ds, attributeNames);

            DecisionTree tree = new DecisionTree(chosenAttribute);
            ConstantDecisonTree m = majorityValue(ds);

            List<String> values = ds.getPossibleAttributeValues(chosenAttribute);
            foreach (String v in values)
            {
                DataSet filtered = ds.matchingDataSet(chosenAttribute, v);
                List<String> newAttribs = Util.removeFrom(attributeNames,
                        chosenAttribute);
                DecisionTree subTree = decisionTreeLearning(filtered, newAttribs, m);
                tree.addNode(v, subTree);

            }

            return tree;
        }
Ejemplo n.º 2
0
 //
 // PRIVATE METHODS
 //
 private DecisionList decisionListLearning(DataSet ds)
 {
     if (ds.size() == 0)
     {
         return new DecisionList(positive, negative);
     }
     List<DLTest> possibleTests = testFactory
             .createDLTestsWithAttributeCount(ds, 1);
     DLTest test = getValidTest(possibleTests, ds);
     if (test == null)
     {
         return new DecisionList(null, FAILURE);
     }
     // at this point there is a test that classifies some subset of examples
     // with the same target value
     DataSet matched = test.matchedExamples(ds);
     DecisionList list = new DecisionList(positive, negative);
     list.add(test, matched.getExample(0).targetValue());
     return list.mergeWith(decisionListLearning(test.unmatchedExamples(ds)));
 }
Ejemplo n.º 3
0
        private List<List<Double>> rawExamplesFromDataSet(DataSet ds,
                Numerizer numerizer) {
		// assumes all values for inout and target are doubles
		List<List<Double>> rds = new List<List<Double>>();
		for (int i = 0; i < ds.size(); i++) {
			List<Double> rexample = new List<Double>();
			Example e = ds.getExample(i);
			Pair<List<Double>, List<Double>> p = numerizer.numerize(e);
			List<Double> attributes = p.getFirst();
			foreach (Double d in attributes) {
				rexample.Add(d);
			}
			List<Double> targets = p.getSecond();
			foreach (Double d in targets) {
				rexample.Add(d);
			}
			rds.Add(rexample);
		}
		return rds;
	}