123456789101112131415161718192021222324252627282930313233343536373839404142 |
- from CertainTrust import Opinion
- from vendors.debian.CSVReader import CSVReader
- class Evaluator:
- @staticmethod
- def evaluate_system(packagefile, months):
- '''
- Generates AND-opinion of a system, based on its package names and months
- :param packagefile: packages installed on the system
- :param months: for how many months the prediction is done
- :return: system evaluation
- '''
- packages=CSVReader.readCSVPackages(packagefile)
- model=CSVReader.readCSVModel(months)
- system={}
- for p in packages:
- if p in model:
- system[p]=model[p]
- return Opinion._cum_and(list(system.values()))
- @staticmethod
- def fuse_models_equal_weights(*models):
- '''
- Fuses models , assume models have equal lists of packages
- :param models: list of model-dictionaries
- :return: fused model-dictionary
- '''
- result_dict = {}
- package_list = list(models[0].keys())
- for p in package_list:
- # get list of items to fuse
- p_ops = []
- for model in models:
- p_ops.append(model[p])
- print(p_ops)
- weights = [1]*len(p_ops)
- # fusion
- fused_op = Opinion._internal_fusion(p_ops, weights)
- result_dict[p]=fused_op
- return result_dict
|