Пример #1
0
 def test_get_scores_for_all_clusters_and_criterias(self):
     criteria = {
                  "criteria 1":{
                             "analysis_1":{
                                           "action": ">",
                                           "weight": 1.0
                                           },
                             "analysis_2":{
                                           "action": "<",
                                           "weight": 0.5
                                           }
                 },
                 "criteria 2":{
                             "analysis_1":{
                                           "action": ">",
                                           "weight": 0.4
                                           },
                             "analysis_2":{
                                           "action": "<",
                                           "weight": 0.2
                                           }
                 }
     }
     
     clustering_info = {
                        'Clustering 1': {
                                          'evaluation': {
                                                         'Normalized_analysis_1': 1,
                                                         'Normalized_analysis_2': 0.3
                                           }   
                         },
                         'Clustering 2': {
                                          'evaluation': {
                                                         'Normalized_analysis_1': 0.7,
                                                         'Normalized_analysis_2': 1.
                                           }
                         }, 
                         'Clustering 3': {
                                          'evaluation': {
                                                         'Normalized_analysis_1': 0.6,
                                                         'Normalized_analysis_2': 0.5
                                           }
                         }, 
                         'Clustering 4': {
                                          'evaluation': {
                                                         'Normalized_analysis_1': 0.9,
                                                         'Normalized_analysis_2': 0.0
                                           }
                         } 
     }
     
     # regression, checked
     self.assertDictEqual({
                          'criteria 1': {
                                         'Clustering 4': 0.9333333333333332, 
                                         'Clustering 2': 0.4666666666666666, 
                                         'Clustering 3': 0.5666666666666667, 
                                         'Clustering 1': 0.9
                                         }, 
                          'criteria 2': {
                                         'Clustering 4': 0.9333333333333332, 
                                         'Clustering 2': 0.46666666666666656, 
                                         'Clustering 3': 0.5666666666666665, 
                                         'Clustering 1': 0.8999999999999999
                                         }
                          },
                          BestClusteringSelector.get_scores_for_all_clusters_and_criterias(criteria, clustering_info))
    def test_get_scores_for_all_clusters_and_criterias(self):
        criteria = {
            "criteria 1": {
                "analysis_1": {
                    "action": ">",
                    "weight": 1.0
                },
                "analysis_2": {
                    "action": "<",
                    "weight": 0.5
                }
            },
            "criteria 2": {
                "analysis_1": {
                    "action": ">",
                    "weight": 0.4
                },
                "analysis_2": {
                    "action": "<",
                    "weight": 0.2
                }
            }
        }

        clustering_info = {
            'Clustering 1': {
                'evaluation': {
                    'Normalized_analysis_1': 1,
                    'Normalized_analysis_2': 0.3
                }
            },
            'Clustering 2': {
                'evaluation': {
                    'Normalized_analysis_1': 0.7,
                    'Normalized_analysis_2': 1.
                }
            },
            'Clustering 3': {
                'evaluation': {
                    'Normalized_analysis_1': 0.6,
                    'Normalized_analysis_2': 0.5
                }
            },
            'Clustering 4': {
                'evaluation': {
                    'Normalized_analysis_1': 0.9,
                    'Normalized_analysis_2': 0.0
                }
            }
        }

        # regression, checked
        self.assertDictEqual(
            {
                'criteria 1': {
                    'Clustering 4': 0.9333333333333332,
                    'Clustering 2': 0.4666666666666666,
                    'Clustering 3': 0.5666666666666667,
                    'Clustering 1': 0.9
                },
                'criteria 2': {
                    'Clustering 4': 0.9333333333333332,
                    'Clustering 2': 0.46666666666666656,
                    'Clustering 3': 0.5666666666666665,
                    'Clustering 1': 0.8999999999999999
                }
            },
            BestClusteringSelector.get_scores_for_all_clusters_and_criterias(
                criteria, clustering_info))