public IModelLabelIterative <double, double> GenerateModelLabelIterative(IDataSet <double, double> training_set)
        {
            //ModelNearestNeighborKDTreeDefault model = new ModelNearestNeighborKDTreeDefault(training_set.DataContext);
            ModelNearestNeighborKDTree <double, double, double> model = new ModelNearestNeighborKDTree <double, double, double>("ModelKNNIneterval", training_set.DataContext, new AlgebraRealFloat64(), new FunctionDistanceEuclidean());
            IList <Tuple <double[], double> > training_instances      = new List <Tuple <double[], double> >();

            for (int instance_index = 0; instance_index < training_set.InstanceCount; instance_index++)
            {
                training_instances.Add(new Tuple <double[], double>(training_set.GetInstanceFeatureData(instance_index), training_set.GetInstanceLabelData(instance_index)[0]));
            }
            model.Add(training_instances);
            return(model);
        }
예제 #2
0
        public IModelDiscreteIterative <DomainType, LabelType> GenerateModelDiscrete(IDataSet <DomainType, LabelType> training_set)
        {
            ModelNearestNeighborKDTree <DomainType, DistanceType, LabelType> model = new ModelNearestNeighborKDTree <DomainType, DistanceType, LabelType>(
                this.DataContext,
                this.kdtree.Copy(),
                this.DistanceFunction,
                this.voting_system,
                this.neighbor_count);
            IList <Tuple <DomainType[], LabelType> > training_instances = new List <Tuple <DomainType[], LabelType> >();

            for (int instance_index = 0; instance_index < training_set.InstanceCount; instance_index++)
            {
                training_instances.Add(new Tuple <DomainType[], LabelType>(training_set.GetInstanceFeatureData(instance_index), training_set.GetInstanceLabelData(instance_index)[0]));
            }
            model.Add(training_instances);
            return(model);
        }