def test_ces_error_estimation_ensemble_bootstrap(self, ens1): # Error estimation using a method that does not take a distance # matrix as input, and therefore relies on bootstrapping the ensembles # instead pytest.importorskip('sklearn') expected_average = 0.03 expected_stdev = 0.02 averages, stdevs = encore.ces( [ens1, ens1], estimate_error=True, bootstrapping_samples=10, clustering_method=encore.KMeans(n_clusters=2), 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=1, err_msg= "Unexpected standard daviation for bootstrapped samples in Clustering Ensemble similarity" )
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)
def test_clustering_method_w_no_distance_matrix(self): cluster_collection = encore.cluster([self.ens1], method=encore.KMeans(10)) print(cluster_collection) assert_equal( len(cluster_collection), 10, err_msg="Unexpected result: {0}".format(cluster_collection))
def test_clustering_KMeans_direct(self, ens1): pytest.importorskip('sklearn') clusters = 10 method = encore.KMeans(clusters) coordinates = ens1.trajectory.timeseries(order='fac') coordinates = np.reshape(coordinates, (coordinates.shape[0], -1)) cluster_assignment, details = method(coordinates) assert len(set(cluster_assignment)) == clusters, \ "Unexpected result: {0}".format(cluster_assignment)
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))
def test_clustering_KMeans_direct(self): clusters = 10 method = encore.KMeans(clusters) coordinates = self.ens1.trajectory.timeseries(format='fac') coordinates = np.reshape(coordinates, (coordinates.shape[0], -1)) cluster_assignment, details = method(coordinates) assert_equal( len(set(cluster_assignment)), clusters, err_msg="Unexpected result: {0}".format(cluster_assignment))
def test_clustering_method_w_no_distance_matrix(self, ens1): pytest.importorskip('sklearn') cluster_collection = encore.cluster([ens1], method=encore.KMeans(10)) assert len(cluster_collection) == 10, \ "Unexpected result: {0}".format(cluster_collection)