示例#1
0
        public void TestClustering()
        {
            var hclust   = new HierarchicalClustering();
            var vals     = TestUtils.ReadMatrix("Examples/clustering_array_copy_error.txt.gz");
            var data     = new FloatMatrixIndexer(vals);
            var distance = new EuclideanDistance();

            hclust.TreeClusterKmeans(data, MatrixAccess.Columns, distance, HierarchicalClusterLinkage.Average, false,
                                     false, 1, 300, 1, 10,
                                     (i) => { });
        }
示例#2
0
        public void TestKmeansClusteringPreculusteringWithManyDuplicateRows()
        {
            HierarchicalClustering hclust = new HierarchicalClustering();
            var values = new float[, ] {
                { 1, 2, 3, 1 }, { 2, 3, 4, 2 }, { 2, 3, 4, 2 }, { 2, 3, 4, 2 }, { 2, 3, 4, 2 }, { 3, 4, 5, 2 }
            };
            FloatMatrixIndexer data = new FloatMatrixIndexer(values);
            var clusterNodes        = hclust.TreeClusterKmeans(data, MatrixAccess.Rows, new EuclideanDistance(), HierarchicalClusterLinkage.Average, false, false, 1,
                                                               5, 1, 1000, i => { });

            Assert.AreEqual(5, clusterNodes.Length);
        }
示例#3
0
        public void TestKmeansClusteringPreculusteringWithDuplicateRows(
            [ValueSource(nameof(_data))] float[,] values,
            [ValueSource(nameof(_linkages))] HierarchicalClusterLinkage linkage,
            [ValueSource(nameof(_distances))] IDistance distance)
        {
            HierarchicalClustering hclust = new HierarchicalClustering();
            FloatMatrixIndexer     data   = new FloatMatrixIndexer(values);
            var clusterNodes = hclust.TreeClusterKmeans(data, MatrixAccess.Columns, distance, linkage, false, false, 1,
                                                        2, 1, 1000, i => { });

            Assert.AreEqual(3, clusterNodes.Length);
        }