private void Gravitational_clustering_test_Click(object sender, RoutedEventArgs e) { clustResultTxtBox.Document.Blocks.Clear(); var clusterization_stopwatch = Stopwatch.StartNew(); string message = null; string path_data = @"F:\Magistry files\test_data\s1_data.txt"; List <DocumentVectorTest> vSpace = TestDocVectorCreator.CreatingTheDocVectorCollection(path_data); List <DocumentVectorTest> normilized_vSpace = TestDocVectorCreator.NormalizationDocumentVectors(vSpace); int M = 500; float G = 6.67408313131313131F * (float)Math.Pow(10, (-6)); float deltaG = 0.001F; float epsilon = 0.1F; float alpha = 0.06F; int clusterNumber = 6; clusterNumber = Convert.ToInt32(txtboxClusterNumber.Text); M = Convert.ToInt32(txtboxIterationCount.Text); string gravitational_label_resul_path = @"F:\Magistry files\data\Gravitational_label_results11.txt"; string Gravitational_report_path = @"F:\Magistry files\reports\Gravitational_reports11.txt"; List <TestCentroid> result = new List <TestCentroid>(normilized_vSpace.Count); var result1 = Tests.Gravitational.GravitationalAlg(normilized_vSpace, G, deltaG, M, epsilon); var get_Clusters = Tests.Gravitational.GetClustersTest(result1, alpha, normilized_vSpace); int[] label_matrix = Tests.Label_Matrix.Label_Matrix_Extractions(get_Clusters, gravitational_label_resul_path); clusterization_stopwatch.Stop(); message = RaportGeneration.RaportGenerationFunction(get_Clusters, get_Clusters.Count, M, clusterization_stopwatch, Gravitational_report_path); clustResultTxtBox.AppendText(message); }
/* * private void AHC_Click(object sender, RoutedEventArgs e) * { * List<string> docCollection = Logic.ClusteringAlgorithms.Used_functions.CreateDocumentCollection2.GenerateDocumentCollection_withoutLazyLoading(); * HashSet<string> termCollection = Logic.ClusteringAlgorithms.Used_functions.TFIDF2ndrealization.getTermCollection(); * Dictionary<string, int> wordIndex = Logic.ClusteringAlgorithms.Used_functions.TFIDF2ndrealization.DocumentsContainsTerm(docCollection, termCollection); * List<DocumentVector> vSpace = VectorSpaceModel.DocumentCollectionProcessing(docCollection); * int iterationCount = 100; * var result = Primitive_Clustering_Hierarhical_Alg.Hierarchical_Clusterization(vSpace, iterationCount); * List<string> docs = Tests.DocClasses.SurveyAndMeasurementsClassOfDocuments_ListCreations(); * List<List<string>> ClassCollection = Tests.DocClasses.ListOfClasses(); * var distance = Tests.InterclusterDistances.d_centroids(result); * var min_centroid_distances = Tests.InterclusterDistances.d_min_centroids(result); * var max_intracluster_d = Tests.IntraclusterDistances.d_max(result); * var min_intracluster_d = Tests.IntraclusterDistances.d_min(result); * var median_intracluster_d = Tests.IntraclusterDistances.d_sr(result); * var Recall_result = Tests.Recall.Recall_Calculating(result, docs); * var Precision_result = Tests.Precision.Precision_Calculating(result, docs); * var Purity = Tests.Purity.Purity_Calculating(result, ClassCollection, vSpace); * var Fmeasure = Tests.F1Measure.F1_Measure_Calculating(result, ClassCollection); * var GMeasure = Tests.F1Measure.G_Measure_Calculating(result, ClassCollection); * var NMI = Tests.NormilizedMutualInformation.NMI_Calculating(result, ClassCollection, vSpace); * } */ #endregion private void Kmeans_test(object sender, RoutedEventArgs e) { #region usual_KMeans_alg_invoke clustResultTxtBox.Document.Blocks.Clear(); var clusterization_stopwatch = Stopwatch.StartNew(); string message = null; string path_data = @"F:\Magistry files\test_data\s1_data.txt"; string KMeansPP_label_resul_path = @"F:\Magistry files\data\test\testData\20Clusters\KMeans_label_result20clust5.txt"; string K_means_report_path = @"F:\Magistry files\reports\KMeans_report20clust5.txt"; int clusterNumber = Convert.ToInt32(txtboxClusterNumber.Text); int iterationCount = 500; iterationCount = Convert.ToInt32(txtboxIterationCount.Text); List <DocumentVectorTest> vSpace = TestDocVectorCreator.CreatingTheDocVectorCollection(path_data); List <DocumentVectorTest> normilized_vSpace = TestDocVectorCreator.NormalizationDocumentVectors(vSpace); List <TestCentroid> firstCentroidList = new List <TestCentroid>(); firstCentroidList = Test_KMeans.CentroidCalculationsForKMeans(normilized_vSpace, clusterNumber); List <TestCentroid> resultSet = Tests.NewTestKMeansClustering.Cluster(vSpace, clusterNumber, iterationCount); int[] KMeans_label_matrix = new int[vSpace.Count]; KMeans_label_matrix = Tests.Label_Matrix.Label_Matrix_Extractions(resultSet, KMeansPP_label_resul_path); clusterization_stopwatch.Stop(); message = RaportGeneration.RaportGenerationFunction(resultSet, clusterNumber, iterationCount, clusterization_stopwatch, K_means_report_path); clustResultTxtBox.AppendText(message); #endregion #region Iterational_test_Kmeans /* * int iteration = 5; * string algorithmFlag = "KMeans"; * int clusterNumbers = Convert.ToInt32(txtboxClusterNumber.Text); * int algiterationCount = 500; * algiterationCount = Convert.ToInt32(txtboxIterationCount.Text); * string test_path_data = @"F:\Magistry files\test_data\s1_data.txt"; * List<DocumentVectorTest>vSpaces = TestDocVectorCreator.CreatingTheDocVectorCollection(test_path_data); * List<DocumentVectorTest> normilized_vSpaces = TestDocVectorCreator.NormalizationDocumentVectors(vSpaces); * List<TestCentroid> firstCentroidLists = new List<TestCentroid>(); * * for (int j = 5; j <= clusterNumbers;) * { * for (int i = 1; i <= iteration; i++) * { * clustResultTxtBox.Document.Blocks.Clear(); * var clusterization_stopwatchs = Stopwatch.StartNew(); * firstCentroidLists = Test_KMeans.CentroidCalculationsForKMeans(normilized_vSpaces, j); * List<TestCentroid> IterationresultSets = Tests.NewTestKMeansClustering.Cluster(vSpaces, j, algiterationCount); * clusterization_stopwatchs.Stop(); * Logic.IterationalReport.IterationalReportGenerationFunction(j, i, algorithmFlag, IterationresultSets, vSpaces.Count, algiterationCount, clusterization_stopwatchs); * } * j +=5; * } */ #endregion }
private void FuzzyKMeansTest_Click(object sender, RoutedEventArgs e) { #region usual_KMeansPP_alg_invoke clustResultTxtBox.Document.Blocks.Clear(); var clusterization_stopwatch = Stopwatch.StartNew(); string message = null; string path_data = @"F:\Magistry files\test_data\s1_data.txt"; List <DocumentVectorTest> vSpace = TestDocVectorCreator.CreatingTheDocVectorCollection(path_data); float fuzziness = 2f; float epsilon = 0.1f; int clusterNumber = Convert.ToInt32(txtboxClusterNumber.Text); List <TestCentroid> resultSet = new List <TestCentroid>(clusterNumber); List <TestCentroid> resultSetRTest = new List <TestCentroid>(); //List<DocumentVectorTest> normilized_vSpace = TestDocVectorCreator.NormalizationDocumentVectors(vSpace); float[,] Result_fcm; //List<string> docs = Tests.DocClasses.SurveyAndMeasurementsClassOfDocuments_ListCreations(); var result = Tests.FuzzyKmeansTest.Fcm(vSpace, clusterNumber, epsilon, fuzziness); Result_fcm = result.Item1; int iterationCount = result.Item2; resultSet = Tests.FuzzyKmeansTest.CreateClusterSet(clusterNumber); var resultSetArray = Tests.FuzzyKmeansTest.AssignDocsToClusters(Result_fcm, clusterNumber, vSpace, resultSet); //resultSetRTest = Tests.FuzzyKmeansTest.AssignDocsToClusters(Result_fcm, clusterNumber, vSpace); string FuzzyKMeans_label_resul_path = @"F:\Magistry files\data\testData\FuzzyKMeans_label_result.txt"; string Fuzzy_K_means_report_path = @"F:\Magistry files\reports\Fuzzy_KMeans_report.txt"; //string RTest_FuzzyKMeans_label_resul_path = @"F:\Magistry files\data\testData\5Clusters\RTest_FuzzyKMeans_label_result5clust1.txt"; string[] string_label_matrix = new string[resultSetArray.Item1.Length]; for (int k = 0; k < resultSetArray.Item1.Length; k++) { string_label_matrix[k] = resultSetArray.Item1[k].ToString(); } var result_Centroid_Set = resultSetArray.Item2; System.IO.File.WriteAllLines(FuzzyKMeans_label_resul_path, string_label_matrix); //string membership_matrix_file_path = @"F:\Magistry files\data\R_membership_matrix.txt"; //var memberShipMatrix = Tests.MemberShipMatrixReader.ReadDataFromFile(membership_matrix_file_path, vSpace.Count, clusterNumber); //resultSet = Tests.FuzzyKmeansTest.CreateClusterSet(clusterNumber); //var resultSetArray1 = Tests.FuzzyKmeansTest.AssignDocsToClusters(memberShipMatrix, clusterNumber, vSpace, resultSet); //for (int k = 0; k < resultSetArray.Item1.Length; k++) //string_label_matrix[k] = resultSetArray1.Item1[k].ToString(); //System.IO.File.WriteAllLines(RTest_FuzzyKMeans_label_resul_path, string_label_matrix); clusterization_stopwatch.Stop(); message = RaportGeneration.RaportGenerationFunction(resultSet, clusterNumber, iterationCount, clusterization_stopwatch, Fuzzy_K_means_report_path); clustResultTxtBox.AppendText(message); #endregion #region Iterational_test_FuzzyKmeans /* * int iteration = 5; * float fuzzinesss = 2f; * float epsilons = 0.1f; * int clusterNumbers = Convert.ToInt32(txtboxClusterNumber.Text); * int algiterationCount = 500; * string algorithm = "FuzzyKMeans"; * algiterationCount = Convert.ToInt32(txtboxIterationCount.Text); * string test_path_data = @"F:\Magistry files\test_data\s1_data.txt"; * List<TestCentroid> resultSets = new List<TestCentroid>(clusterNumbers); * List<DocumentVectorTest> vSpaces = TestDocVectorCreator.CreatingTheDocVectorCollection(test_path_data); * List<DocumentVectorTest> normilized_vSpaces = TestDocVectorCreator.NormalizationDocumentVectors(vSpaces); * * for (int j = 5; j <= clusterNumbers;) * { * for (int i = 1; i <= iteration; i++) * { * * clustResultTxtBox.Document.Blocks.Clear(); * var clusterizations_stopwatchs = Stopwatch.StartNew(); * float[,] Result_fcms; * var results = Tests.FuzzyKmeansTest.Fcm(vSpaces, j, epsilons, fuzzinesss); * Result_fcms = results.Item1; * int AlgiterationCounts = results.Item2; * resultSets = Tests.FuzzyKmeansTest.CreateClusterSet(j); * var resultSetArrays = Tests.FuzzyKmeansTest.AssignDocsToClusters(Result_fcms, j, vSpaces, resultSets); * string[] string_label_matrixs = new string[resultSetArrays.Item1.Length]; * for (int k = 0; k < resultSetArrays.Item1.Length; k++) * string_label_matrixs[k] = resultSetArrays.Item1[k].ToString(); * string FuzzyKMeans_label_resul_paths = @"F:\Magistry files\data\test\testData\" + j.ToString() + "Clusters\\FuzzyKMeans_label_result" + j.ToString() + "clust" + i.ToString() + ".txt"; * string Fuzzy_K_means_report_paths = @"F:\Magistry files\reports\test\Fuzzy_KMeans_report" + j.ToString() + "clust" + i.ToString() + ".txt"; * clusterizations_stopwatchs.Stop(); * using (StreamWriter w = File.AppendText(FuzzyKMeans_label_resul_paths)) * { * for (int k = 0; k < string_label_matrixs.Length; k++) * w.WriteLine(string_label_matrixs[k]); * } * RaportGeneration.VoidRaportGenerationFunction(algorithm, resultSetArrays.Item2, j, AlgiterationCounts, clusterizations_stopwatchs, Fuzzy_K_means_report_paths); * } * j += 5; * } */ #endregion }