public override LabelType GetLabel(DomainType[] instance_features) { NearestNeighbourEnumerator <DomainType, DistanceType, LabelType> enumerator = kdtree.NearestNeighbors(instance_features, DistanceFunction, default(DistanceType), default(DistanceType), false, neighbor_count); IList <Tuple <DomainType[], DistanceType, LabelType> > neighbors = new List <Tuple <DomainType[], DistanceType, LabelType> >(); do { neighbors.Add(enumerator.Current); }while (enumerator.MoveNext()); return(voting_system.elect(neighbors).Item3); }
public override LabelType GetLabel(DomainType[] instance_features) { IList <Tuple <DomainType[], DistanceType, LabelType> > neighbors = new List <Tuple <DomainType[], DistanceType, LabelType> >(); foreach (Tuple <DomainType[], LabelType> neighbor in this.list) { neighbors.Add(new Tuple <DomainType[], DistanceType, LabelType>(neighbor.Item1, this.distance_function.Compute(neighbor.Item1, instance_features), neighbor.Item2)); } List <Tuple <DomainType[], DistanceType, LabelType> > ordered_neighbors = new List <Tuple <DomainType[], DistanceType, LabelType> >(neighbors.OrderBy(tuple => tuple.Item2)); Tuple <DomainType[], DistanceType, LabelType>[] selected_neighbors = ToolsCollection.Crop(ordered_neighbors, this.neighbor_count); return(voting_system.elect(selected_neighbors).Item3); }