示例#1
0
 def test_clustering_two_methods(self, ens1):
     cluster_collection = encore.cluster(
         [ens1],
         method=[
             encore.AffinityPropagationNative(),
             encore.AffinityPropagationNative()
         ])
     assert len(cluster_collection[0]) == len(cluster_collection[1]), \
                  "Unexpected result: {0}".format(cluster_collection)
示例#2
0
 def test_clustering_two_methods(self):
     cluster_collection = encore.cluster(
         [self.ens1],
         method=[
             encore.AffinityPropagationNative(),
             encore.AffinityPropagationNative()
         ])
     assert_equal(
         len(cluster_collection[0]),
         len(cluster_collection[1]),
         err_msg="Unexpected result: {0}".format(cluster_collection))
示例#3
0
 def test_clustering_AffinityPropagationNative_direct(self, ens1):
     method = encore.AffinityPropagationNative()
     distance_matrix = encore.get_distance_matrix(ens1)
     cluster_assignment, details = method(distance_matrix)
     expected_value = 7
     assert len(set(cluster_assignment)) == expected_value, \
                  "Unexpected result: {0}".format(cluster_assignment)
示例#4
0
    def test_ces_error_estimation(self, ens1):
        expected_average = 0.03
        expected_stdev = 0.31
        averages, stdevs = encore.ces(
            [ens1, ens1],
            estimate_error=True,
            bootstrapping_samples=10,
            clustering_method=encore.AffinityPropagationNative(
                preference=-2.0),
            selection="name CA and resnum 1-10")
        average = averages[0, 1]
        stdev = stdevs[0, 1]

        assert_almost_equal(
            average,
            expected_average,
            decimal=1,
            err_msg=
            "Unexpected average value for bootstrapped samples in Clustering Ensemble similarity"
        )
        assert_almost_equal(
            stdev,
            expected_stdev,
            decimal=0,
            err_msg=
            "Unexpected standard daviation  for bootstrapped samples in Clustering Ensemble similarity"
        )
示例#5
0
 def test_clustering_two_methods_one_w_no_distance_matrix(self, ens1):
     pytest.importorskip('sklearn')
     cluster_collection = encore.cluster(
         [ens1],
         method=[encore.KMeans(17),
                 encore.AffinityPropagationNative()])
     assert len(cluster_collection[0]) == len(cluster_collection[0]), \
                  "Unexpected result: {0}".format(cluster_collection)
示例#6
0
 def test_one(self, distance_matrix):
     preference = -float(np.median(distance_matrix.as_array()) * 10.)
     clustering_method = encore.AffinityPropagationNative(
         preference=preference)
     ccs = encore.cluster(None,
                          distance_matrix=distance_matrix,
                          method=clustering_method)
     assert self.n_clusters == len(ccs), \
                  "Basic clustering test failed to give the right"\
                 "number of clusters: {0} vs {1}".format(self.n_clusters, len(ccs))
示例#7
0
 def test_clustering_two_methods_one_w_no_distance_matrix(self):
     cluster_collection = encore.cluster(
         [self.ens1],
         method=[encore.KMeans(17),
                 encore.AffinityPropagationNative()])
     print(cluster_collection)
     assert_equal(
         len(cluster_collection[0]),
         len(cluster_collection[0]),
         err_msg="Unexpected result: {0}".format(cluster_collection))
示例#8
0
 def test_ces_to_self(self, ens1):
     results, details = \
         encore.ces([ens1, ens1],
         clustering_method=encore.AffinityPropagationNative(preference = -3.0))
     result_value = results[0, 1]
     expected_value = 0.
     assert_almost_equal(
         result_value,
         expected_value,
         err_msg="ClusteringEnsemble Similarity to itself not zero: {0:f}".
         format(result_value))