예제 #1
0
 public ModelNearestNeighborKDTree(
     IDataContext data_contex,
     IAlgebraReal <DomainType> algebra,
     IFunctionDistance <DomainType [], DistanceType> distance_function)
     : this(data_contex, algebra, distance_function, new SingleVoteSystem <Tuple <DomainType[], DistanceType, LabelType> >(), 1)
 {
 }
예제 #2
0
        /// <summary>
        /// Construct a new nearest neighbour iterator.
        /// </summary>
        /// <param name="pRoot">The root of the tree to begin searching from.</param>
        /// <param name="tSearchPoint">The point in n-dimensional space to search.</param>
        /// <param name="distance_function">The distance function used to evaluate the points.</param>
        /// <param name="max_result_count">The max number of points which can be returned by this iterator.  Capped to max in tree.</param>
        /// <param name="threshold">Threshold to apply to the search space.  Negative numbers indicate that no threshold is applied.</param>
        public NearestNeighbourEnumerator(DistanceType distance_zero, KDNode <DomainType, DistanceType, LabelType> pRoot, DomainType[] tSearchPoint, IFunctionDistance <DomainType[], DistanceType> distance_function, int max_result_count, DistanceType threshold, bool use_threshold)
        {
            // Check the dimensionality of the search point.
            if (tSearchPoint.Length != pRoot.d_dimension_count)
            {
                throw new Exception("Dimensionality of search point and kd-tree are not the same.");
            }

            //this.algebra_domain = algebra;

            // Store the search point.
            this.search_point = new DomainType[tSearchPoint.Length];
            Array.Copy(tSearchPoint, this.search_point, tSearchPoint.Length);

            // Store the point count, distance function and tree root.
            this.iPointsRemaining = Math.Min(max_result_count, pRoot.Size);
            this.fThreshold       = threshold;
            this.d_use_threshold  = use_threshold;

            this.distance_function  = distance_function;
            this.pRoot              = pRoot;
            this.iMaxPointsReturned = max_result_count;

            this._CurrentDistance       = distance_zero;
            this.d_current_distance_set = false;
            this.distance_zero          = distance_zero;
            // Create an interval heap for the points we check.
            this.pEvaluated = new IntervalHeap <LabelType, DistanceType>();

            // Create a min heap for the things we need to check.
            this.pPending = new MinHeap <KDNode <DomainType, DistanceType, LabelType>, DistanceType>();
            this.pPending.Insert(distance_zero, pRoot);
        }
예제 #3
0
 public ModelLVQDefault(IDataContext data_context, IList <double[]> prototype_features, IList <int> prototype_labels, IFunctionDistance <double[], double> distance_function)
     : base(data_context, "ModelLVQDefault")
 {
     this.prototype_features = prototype_features;
     this.prototype_labels   = prototype_labels;
     this.distance_function  = distance_function;
     this.FeatureCount       = prototype_features[0].Length;
 }
예제 #4
0
 public TemplateModelLVQ(IFunctionDistance <double[], double> distance_function, int prototype_count, double learning_rate, int epoch_count, RandomNumberGenerator random)
 {
     this.random            = random;
     this.distance_function = distance_function;
     this.prototype_count   = prototype_count;
     this.LearningRate      = learning_rate;
     this.epoch_count       = epoch_count;
 }
예제 #5
0
 public ModelNearestNeighborList(
     IDataContext data_contex,
     IFunctionDistance <DomainType[], DistanceType> distance_function,
     IVotingSystem <Tuple <DomainType[], DistanceType, LabelType> > voting_system,
     int neighbor_count)
     : this(data_contex, new List <Tuple <DomainType [], LabelType> >(), distance_function, voting_system, neighbor_count)
 {
 }
예제 #6
0
 public ModelNearestNeighborKDTree(
     IDataContext data_contex,
     IAlgebraReal <DomainType> algebra,
     IFunctionDistance <DomainType[], DistanceType> distance_function,
     IVotingSystem <Tuple <DomainType[], DistanceType, LabelType> > voting_system,
     int neighbor_count)
     : this(data_contex, new KDTree <DomainType, DistanceType, LabelType>(algebra, data_contex.FeatureCount), distance_function, voting_system, neighbor_count)
 {
 }
예제 #7
0
 public ModelNearestNeighborKDTree(
     IDataContext data_contex,
     KDTree <DomainType, DistanceType, LabelType> kdtree,
     IFunctionDistance <DomainType[], DistanceType> distance_function,
     IVotingSystem <Tuple <DomainType[], DistanceType, LabelType> > voting_system,
     int neighbor_count)
     : this("ModelNearestNeighborKDTree", data_contex, kdtree, distance_function, voting_system, neighbor_count)
 {
     this.kdtree           = kdtree;
     this.DistanceFunction = distance_function;
     this.voting_system    = voting_system;
     this.neighbor_count   = neighbor_count;
 }
예제 #8
0
 public ModelNearestNeighborList(
     IDataContext data_contex,
     IList <Tuple <DomainType[], LabelType> > list,
     IFunctionDistance <DomainType[], DistanceType> distance_function,
     IVotingSystem <Tuple <DomainType[], DistanceType, LabelType> > voting_system,
     int neighbor_count)
     : base(data_contex, "ModelNearestNeighborList")
 {
     this.list = list;
     this.distance_function = distance_function;
     this.voting_system     = voting_system;
     this.neighbor_count    = neighbor_count;
 }
예제 #9
0
 public ASLIC(
     int iteration_count,
     int [] cluster_dimensions,
     IFunctionDistance <DomainType, float> distance_features,
     IFunction <IList <DomainType>, DomainType> centroid_calculator,
     float feature_weight)
 {
     this.d_iteration_count             = iteration_count;
     this.d_cluster_dimensions          = cluster_dimensions;
     this.d_cluster_dimensions_double   = ToolsMathCollectionInteger.Multiply(d_cluster_dimensions, 2);
     this.d_distance_features           = distance_features;
     this.d_centroid_feature_calculator = centroid_calculator;
     this.feature_weight = feature_weight;
 }
예제 #10
0
 public FunctionDistanceToTarget(IFunctionDistance <DomaineType, DistanceType> distance_function, DomaineType target)
 {
     d_distance_function = distance_function;
     d_target            = target;
 }
예제 #11
0
 public TemplateCentroidCalculatorMeanFloatArray(IFunctionDistance <float[], float> distance_function)
 {
     this.distance_function = distance_function;
 }
예제 #12
0
 public CentroidFloat32(IFunctionDistance <float[], float> distance_function, IList <float[]> instance_feature_list, float[] location)
 {
     this.distance_function = distance_function;
     this.Members           = new List <float[]>(instance_feature_list);
     this.location          = ToolsCollection.Copy(location);
 }
예제 #13
0
 public TemplateModelLVQ(IFunctionDistance <double[], double> distance_function, int prototype_count, double learning_rate, int epoch_count)
     : this(distance_function, prototype_count, learning_rate, epoch_count, new RNGCryptoServiceProvider())
 {
 }
예제 #14
0
 /// <summary>
 /// Get the nearest neighbours to a point in the kd tree using a user defined distance function.
 /// </summary>
 /// <param name="search_point">The point of interest.</param>
 /// <param name="max_result_count">The maximum number of points which can be returned by the iterator.</param>
 /// <param name="kDistanceFunction">The distance function to use.</param>
 /// <param name="threshold">A threshold distance to apply.  Optional.  Negative values mean that it is not applied.</param>
 /// <returns>A new nearest neighbour iterator with the given parameters.</returns>
 public NearestNeighbourEnumerator <DomainType, DistanceType, LabelType> NearestNeighbors(DomainType[] search_point, IFunctionDistance <DomainType[], DistanceType> distance_function, DistanceType distance_zero, DistanceType threshold, bool use_threshold, int max_result_count)
 {
     return(new NearestNeighbourEnumerator <DomainType, DistanceType, LabelType>(distance_zero, this, search_point, distance_function, max_result_count, threshold, true));
 }
예제 #15
0
 public ModelNearestNeighborList(
     IDataContext data_contex,
     IFunctionDistance <DomainType[], DistanceType> distance_function)
     : this(data_contex, distance_function, new SingleVoteSystem <Tuple <DomainType[], DistanceType, LabelType> >(), 1)
 {
 }