Skip to content

Commit

Permalink
Updated output format
Browse files Browse the repository at this point in the history
  • Loading branch information
mrosvall committed Mar 10, 2020
1 parent ee893fe commit d44d179
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 21 deletions.
30 changes: 14 additions & 16 deletions README.rst
Expand Up @@ -55,26 +55,24 @@ with distance threshold 0.2, run::
and generate output files::

output_clustering.txt
# Clustered 10 partitions into 2 clusters.
# ClusterId PartitionId
# Cluster 1: 5 partitions.
1 1
1 2
1 3
1 4
1 5
# Cluster 2: 5 partitions.
2 6
2 7
2 8
2 9
2 10
# Clustered 10 partitions into 2 clusters.
# ClusterId PartitionId
1 1
1 2
1 3
1 4
1 5
2 6
2 7
2 8
2 9
2 10

and::

output_clustering_distances.txt
# PartitionId_of_cluster_center1 PartitionId_of_cluster_center2 distance Size_of_cluster_center1 Size_of_cluster_center2
1 6 0.398148148148148 5 5
# ClusterId1 ClusterId2 Distance
1 2 0.398148148148148

To validate the same hierarchical partitions with 5 training and 5 validation partitions sampled 10 times, run::
Expand Down
18 changes: 13 additions & 5 deletions partition-validation.h
Expand Up @@ -444,7 +444,7 @@ void Partitions::printClusters(){
ofs << "# Clustered " << NtrainingPartitions << " partitions into " << clusters.size() << " clusters." << endl;
ofs << "# ClusterId PartitionId" << endl;
for(Clusters::iterator cluster_it = clusters.begin(); cluster_it != clusters.end(); cluster_it++){
ofs << "# Cluster " << i << ": " << cluster_it->size() << " partitions." << endl;
// ofs << "# Cluster " << i << ": " << cluster_it->size() << " partitions." << endl;
for(vector<Partition *>::iterator partition_it = cluster_it->begin(); partition_it != cluster_it->end(); partition_it++)
ofs << i << " " << (*partition_it)->partitionId+1 << endl;

Expand All @@ -460,10 +460,18 @@ void Partitions::printClusters(){
else
distanceOutFileName.insert(period_pos,"_distances");
ofs.open(distanceOutFileName.c_str());
ofs << "# PartitionId_of_cluster_center1 PartitionId_of_cluster_center2 distance Size_of_cluster_center1 Size_of_cluster_center2" << endl;
for(Clusters::iterator cluster_it1 = clusters.begin(); cluster_it1 != clusters.end(); cluster_it1++)
for(Clusters::iterator cluster_it2 = next(cluster_it1); cluster_it2 != clusters.end(); cluster_it2++)
ofs << (*cluster_it1->begin())->partitionId+1 << " " << (*cluster_it2->begin())->partitionId+1 << " " << wpJaccardDist(*cluster_it1->begin(),*cluster_it2->begin()) << " " << cluster_it1->size() << " " << cluster_it2->size() << endl;
i = 1;
ofs << "# ClusterId1 ClusterId2 Distance" << endl;
for(Clusters::iterator cluster_it1 = clusters.begin(); cluster_it1 != clusters.end(); cluster_it1++){
int j = i+1;
for(Clusters::iterator cluster_it2 = next(cluster_it1); cluster_it2 != clusters.end(); cluster_it2++){
// ofs << (*cluster_it1->begin())->partitionId+1 << " " << (*cluster_it2->begin())->partitionId+1 << " " << wpJaccardDist(*cluster_it1->begin(),*cluster_it2->begin()) << endl;
ofs << i << " " << j << " " << wpJaccardDist(*cluster_it1->begin(),*cluster_it2->begin()) << endl;
j++;
}

i++;
}

ofs.close();
cout << "done!" << endl;
Expand Down

0 comments on commit d44d179

Please sign in to comment.