def min_max_normalize(scores): s_min, s_max = min(scores), max(scores) if s_min == s_max: return [0.5] * len(scores) return [(s - s_min) / (s_max - s_min) for s in scores] def evaluate_directions(directions, weights): ranking = {} for name, dims in directions.items(): keys = list(dims.keys()) raw = [dims[k] for k in keys] norm = min_max_normalize(raw) total = sum(norm[i] * weights[keys[i]] for i in range(len(keys))) ranking[name] = round(total / sum(weights.values()), 3) return sorted(ranking.items(), key=lambda x: x[1], reverse=True) if name == "main": directions = { "CV": {"interest": 8, "ability": 7, "prospect": 9, "resource": 6}, "NLP": {"interest": 9, "ability": 8, "prospect": 10, "resource": 7}, "RL": {"interest": 6, "ability": 6, "prospect": 6, "resource": 8}, "MLSys": {"interest": 7, "ability": 9, "prospect": 7, "resource": 9}, } weights = {"interest": 0.4, "ability": 0.2, "prospect": 0.3, "resource": 0.1} for name, score in evaluate_directions(directions, weights): print(name, score) ```
代码用途:用加权评分 + min-max 归一化在多个候选研究方向之间做决策排序,对应文中的“综合决策框架”。