Esempio n. 1
0
def main():
    option_parser, opts, args = parse_command_line_parameters(**script_info)

    if opts.output_path != None:
        outf = open(opts.output_path, 'w')
    else:
        outf = sys.stdout

    dists = parse_distmat(open(opts.input_path, 'U'))
    map_data = parse_mapping_file_to_dict(open(opts.map, 'U'))
    diff_dists, same_dists = clust_qual_ratio(dists, map_data, opts.category)

    if opts.short:
        print >> outf, numpy.mean(diff_dists) / numpy.mean(same_dists)
    else:
        print >> outf, "dissimilarity ratio between/within (large for clustered data):"
        print >> outf, numpy.mean(diff_dists) / numpy.mean(same_dists)
        print >> outf, "dissimilarities between clusters: mean, std, num:"
        print >> outf, '\t'.join(
            map(str, [
                numpy.mean(diff_dists),
                numpy.std(diff_dists),
                len(diff_dists)
            ]))
        print >> outf, "dissimilarities within clusters: mean, std, num:"
        print >> outf, '\t'.join(
            map(str, [
                numpy.mean(same_dists),
                numpy.std(same_dists),
                len(same_dists)
            ]))
Esempio n. 2
0
def main():
    option_parser, opts, args = parse_command_line_parameters(**script_info)

    if opts.output_path != None:
        outf = open(opts.output_path,'w')
    else:
        outf = sys.stdout

    dists = parse_distmat(open(opts.input_path,'U'))
    map_data = parse_mapping_file_to_dict(open(opts.map,'U'))
    diff_dists, same_dists = clust_qual_ratio(dists, map_data, opts.category)



    if opts.short:
        print >> outf, numpy.mean(diff_dists)/numpy.mean(same_dists)
    else:
        print >> outf, "dissimilarity ratio between/within (large for clustered data):"
        print >> outf, numpy.mean(diff_dists)/numpy.mean(same_dists)
        print >> outf, "dissimilarities between clusters: mean, std, num:"
        print >> outf, '\t'.join(map(str,[numpy.mean(diff_dists), numpy.std(diff_dists),
         len(diff_dists)]))
        print >> outf, "dissimilarities within clusters: mean, std, num:"
        print >> outf, '\t'.join(map(str,[numpy.mean(same_dists), numpy.std(same_dists),
         len(same_dists)]))
Esempio n. 3
0
 def test_clust_qual_ratio(self):
     dist_labels = ["s1", "s2", "s3"]
     dmtx = numpy.array([[0, 2.1, 3], [2.1, 0, 1], [3, 1, 0]])
     dists = [dist_labels, dmtx]
     map_data = {"s1": {"color": "red"}, "s2": {"color": "blue"}, "s3": {"color": "red"}}
     bet, within = clust_qual_ratio(dists, [map_data, []], "color")
     assert_almost_equal(sorted(bet), [1, 2.1])
     assert_almost_equal(within, [3.0])
Esempio n. 4
0
 def test_clust_qual_ratio(self):
     dist_labels = ['s1','s2','s3']
     dmtx = numpy.array([[0,2.1,3],[2.1,0,1],[3,1,0]])
     dists = [dist_labels,dmtx]
     map_data = \
         {'s1':{'color':'red'},'s2':{'color':'blue'},'s3':{'color':'red'}}
     bet, within = clust_qual_ratio(dists, [map_data,[]], 'color')
     self.assertFloatEqual( sorted(bet), [1,2.1])
     self.assertFloatEqual(within, [3.])
Esempio n. 5
0
 def test_clust_qual_ratio(self):
     dist_labels = ['s1','s2','s3']
     dmtx = numpy.array([[0,2.1,3],[2.1,0,1],[3,1,0]])
     dists = [dist_labels,dmtx]
     map_data = \
         {'s1':{'color':'red'},'s2':{'color':'blue'},'s3':{'color':'red'}}
     bet, within = clust_qual_ratio(dists, [map_data,[]], 'color')
     self.assertFloatEqual( sorted(bet), [1,2.1])
     self.assertFloatEqual(within, [3.])