AIMA.Core.Learning.Framework.DataSet.matchingDataSet C# (CSharp) Метод

matchingDataSet() публичный Метод

public matchingDataSet ( String attributeName, String attributeValue ) : DataSet
attributeName String
attributeValue String
Результат DataSet
        public DataSet matchingDataSet(String attributeName, String attributeValue)
        {
            DataSet ds = new DataSet(specification);
            foreach (Example e in examples)
            {
                if (e.getAttributeValueAsString(attributeName).Equals(
                        attributeValue))
                {
                    ds.add(e);
                }
            }
            return ds;
        }

Usage Example

Пример #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;
        }