Advanced Chunk Processing Library 0.2.0
A comprehensive C++ library for advanced data chunking strategies and processing operations
Loading...
Searching...
No Matches
chunk_metrics.cpp File Reference
#include "chunk_metrics.hpp"
#include <iostream>
#include <string>
#include <vector>
+ Include dependency graph for chunk_metrics.cpp:

Go to the source code of this file.

Functions

int main (int argc, char *argv[])
 

Function Documentation

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 6 of file chunk_metrics.cpp.

6 {
7 try {
8 // Create test data
9 std::vector<std::vector<double>> well_separated = {
10 {1.0, 1.1, 1.2},
11 {5.0, 5.1, 5.2},
12 {10.0, 10.1, 10.2}
13 };
14
15 std::vector<std::vector<double>> mixed_chunks = {
16 {1.0, 1.1, 5.0},
17 {2.0, 2.1, 8.0},
18 {3.0, 3.1, 9.0}
19 };
20
21 // Create analyzer
23
24 // Check for debug flag
25 bool debug = (argc > 1 && std::string(argv[1]) == "--debug");
26
27 // Compute and display metrics
28 std::cout << "\nComputing chunk metrics...\n" << std::endl;
29
30 try {
31 // Cohesion metrics
32 double high_cohesion = analyzer.compute_cohesion(well_separated);
33 double mixed_cohesion = analyzer.compute_cohesion(mixed_chunks);
34
35 std::cout << "Cohesion Metrics:" << std::endl;
36 std::cout << " Well-separated chunks: " << high_cohesion << std::endl;
37 std::cout << " Mixed cohesion chunks: " << mixed_cohesion << std::endl;
38
39 // Separation metrics
40 double separation = analyzer.compute_separation(well_separated);
41 std::cout << "\nSeparation Metric: " << separation << std::endl;
42
43 // Silhouette score
44 double silhouette = analyzer.compute_silhouette_score(well_separated);
45 std::cout << "Silhouette Score: " << silhouette << std::endl;
46
47 // Quality scores
48 double high_quality = analyzer.compute_quality_score(well_separated);
49 double mixed_quality = analyzer.compute_quality_score(mixed_chunks);
50
51 std::cout << "\nQuality Scores:" << std::endl;
52 std::cout << " Well-separated chunks: " << high_quality << std::endl;
53 std::cout << " Mixed cohesion chunks: " << mixed_quality << std::endl;
54
55 // Size metrics
56 auto size_metrics = analyzer.compute_size_metrics(well_separated);
57 std::cout << "\nSize Metrics:" << std::endl;
58 for (const auto& [metric, value] : size_metrics) {
59 std::cout << " " << metric << ": " << value << std::endl;
60 }
61
62 if (debug) {
63 std::cout << "\nDebug Information:" << std::endl;
64 std::cout << " Number of chunks: " << well_separated.size() << std::endl;
65 std::cout << " Chunk sizes: ";
66 for (const auto& chunk : well_separated) {
67 std::cout << chunk.size() << " ";
68 }
69 std::cout << std::endl;
70 }
71
72 } catch (const std::exception& e) {
73 std::cerr << "Error computing metrics: " << e.what() << std::endl;
74 return 1;
75 }
76
77 std::cout << "\nMetrics computation completed successfully.\n" << std::endl;
78 return 0;
79
80 } catch (const std::exception& e) {
81 std::cerr << "Fatal error: " << e.what() << std::endl;
82 return 1;
83 }
84}
std::map< std::string, double > compute_size_metrics(const std::vector< std::vector< T > > &chunks) const
double compute_quality_score(const std::vector< std::vector< T > > &chunks) const
double compute_separation(const std::vector< std::vector< T > > &chunks) const
double compute_cohesion(const std::vector< std::vector< T > > &chunks) const
double compute_silhouette_score(const std::vector< std::vector< T > > &chunks) const

References chunk_metrics::ChunkQualityAnalyzer< T >::compute_cohesion(), chunk_metrics::ChunkQualityAnalyzer< T >::compute_quality_score(), chunk_metrics::ChunkQualityAnalyzer< T >::compute_separation(), chunk_metrics::ChunkQualityAnalyzer< T >::compute_silhouette_score(), and chunk_metrics::ChunkQualityAnalyzer< T >::compute_size_metrics().