class TopsisEvaluator(BaseEvaluator):
    def __init__(self, candidate_names=None):
        self.candidate_names = candidate_names
        self.data_topsis = None

    def get_optimal_candidates(self, candidates, criteria):
        names = self.candidate_names.iloc[candidates.index].values

        min_max = []
        weights = []
        columns = []

        for c in criteria:
            if c.maximize:
                min_max.append(MAX)
            else:
                min_max.append(MIN)

            weights.append(c.weight)
            columns.append(c.index)

        self.data_topsis = Data(candidates[columns].as_matrix().tolist(),
                                min_max,
                                weights=weights,
                                anames=names,
                                cnames=columns)
        model = closeness.TOPSIS()
        choice = model.decide(self.data_topsis)
        return [candidates.index[int(choice.best_alternative_)]
                ]  # Return must be a list

    def print(self):
        if self.data_topsis != None:
            self.data_topsis.plot()
Example #2
0
        0.0555555555555556, 0.0555555555555556, 0.0555555555555556
    ],
    anames=[
        "SriLanka", "India", "England", "South Africa", "Australia",
        "NewZealand", "Pakistan", "West Indies", "Bangladesh", "Zimbabwe",
        "Ireland"
    ],
    cnames=[
        "Run", "HS", "Average", "BF", "Strikerate", "Centuries", "Fifties",
        "zeros", "Fours", "Sixes", "Maiden", "Runs_bowl", "Wickets",
        "Average_bowling", "Economical", "Strikerate_bowl", "4wickets",
        "5wickets"
    ])

#data.plot();
data.plot("box")

#data.plot.violin();
#data.plot.radar(cmap="inferno", show_criteria=False);

# first create the decision maker
# (with the default hiper parameters)
dm = simple.WeightedSum()
print(dm)
# Now lets decide the ranking
dec = dm.decide(data)
print(dec)

print(dec.e_)
print(dec.e_.points)