예제 #1
0
        public GaussianNoiseDistance(IDistance <T> distance, float std)
        {
            distance.NullCheck();
            (std >= 0).AssertTrue();

            this.InnerDistance     = distance;
            this.StandardDeviation = std;

            this.normal = new Normal(this.Mean, this.StandardDeviation);
        }
        public NGramSemanticGraphDistance(IDistance <float> e, Func <float, float> transform, float tolerance = 0F, float empty = 1F)
        {
            e.NullCheck();
            transform.NullCheck();

            this.TolerancePerNode = tolerance;
            this.EmptyNodeWeight  = empty;

            this.ProbabilityDistace = e;
            this.TransformFunction  = transform;
        }
예제 #3
0
        public KMeans(IEnumerable <T[]> vectors, IDistance <T> func, int k, int[] centers)
        {
            vectors.NullCheck();
            centers.NullCheck();
            func.NullCheck();

            (centers.Length == k).AssertTrue();

            this.values   = vectors.ToArray();
            this.Function = func;
            this.K        = k;
            this.centers  = new Dictionary <T[], List <T[]> >();
            foreach (var item in centers)
            {
                if (!this.centers.ContainsKey(this.values[item]))
                {
                    this.centers.Add(this.values[item], new List <T[]>());
                }
            }
            this.AssignToNewCenters();
        }