Pandas 是否内置了多目标排序算法?
我找到了 this这是一个 NSGA-II 算法(这是我想要的),但它需要将目标函数作为单独的文件传递。在一个理想的世界中,我会为所有数据使用 DataFrame,在指定目标函数列(和其他必需参数)的同时调用类似 multi_of_sort 的方法,它会返回另一个 DataFrame帕累托最优值。
这对于 Pandas 来说似乎是微不足道的,但我可能是错的。
请您参考如下方法:
事实证明...上面引用的 pareto 包确实处理 DataFrame 输入。
import pareto
import pandas as pd
# load the data
df = pd.read_csv('data.csv')
# define the objective function column indices
# optional. default is ALL columns
of_cols = [4, 5]
# define the convergence tolerance for the OF's
# optional. default is 1e-9
eps_tols = [1, 2]
# sort
nondominated = pareto.eps_sort([list(df.itertuples(False))], of_cols, eps_tols)
# convert multi-dimension array to DataFrame
df_pareto = pd.DataFrame.from_records(nondominated, columns=list(df.columns.values))
