Algorithm-LinearManifoldDataClusterer

 view release on metacpan or  search on metacpan

lib/Algorithm/LinearManifoldDataClusterer.pm  view on Meta::CPAN

438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
        push @array_of_partitioned_cluster_groups, $partitioned_cluster_groups[1];
    }
}
my @data_clustered;
foreach my $cluster (@final_clusters) {
    push @data_clustered, @$cluster;
}
unless (scalar(@data_clustered) == scalar(@{$self->{_data_tags}})) {
    $self->{_final_clusters} = \@final_clusters;
    my %data_clustered = map {$_ => 1} @data_clustered;
    my @data_tags_not_clustered =
           grep {$_} map {exists $data_clustered{$_} ? undef : $_} @{$self->{_data_tags}};
    if ($self->{_terminal_output}) {
        print "\n\nNot all data clustered.  The most reliable clusters found by graph partitioning:\n";
        display_clusters(\@final_clusters);
        print "\n\nData not yet clustered:\n\n@data_tags_not_clustered\n";
    }
    if ($self->{_data_dimensions} == 3) {
        $visualization_msg = "$self->{_K}_best_clusters_produced_by_graph_partitioning";
        $self->visualize_clusters_on_sphere($visualization_msg, \@final_clusters)
            if $self->{_visualize_each_iteration};
        $self->visualize_clusters_on_sphere($visualization_msg, \@final_clusters, "png")
            if $self->{_make_png_for_each_iteration};
    }
    my %data_tags_to_cluster_label_hash;
    foreach my $i (0..@final_clusters-1) {
        map {$data_tags_to_cluster_label_hash{$_} = $i} @{$final_clusters[$i]};
    }
    $self->{_data_tags_to_cluster_label_hash} = \%data_tags_to_cluster_label_hash;
    foreach my $tag (@data_tags_not_clustered) {
        my $which_cluster = $self->which_cluster_for_new_element($tag);
        $self->{_data_tags_to_cluster_label_hash}->{$tag} = $which_cluster;
    }
    die "Some data elements are still missing from the final tally"
      unless scalar(keys %{$self->{_data_tags_to_cluster_label_hash}}) ==
        scalar(@{$self->{_data_tags}});
    my @new_final_clusters;
    map { foreach my $ele (keys %{$self->{_data_tags_to_cluster_label_hash}}) {
              push @{$new_final_clusters[$_]}, $ele
                    if $self->{_data_tags_to_cluster_label_hash}->{$ele} == $_ }



( run in 0.260 second using v1.01-cache-2.11-cpan-95122f20152 )