跳到正文

工具类

此文件是 TPOT 库的一部分。

TPOT 的当前版本由 Cedars-Sinai 的以下人员开发: - Pedro Henrique Ribeiro (https://github.com/perib, https://www.linkedin.com/in/pedro-ribeiro/) - Anil Saini (anil.saini@cshs.org) - Jose Hernandez (jgh9094@gmail.com) - Jay Moran (jay.moran@cshs.org) - Nicholas Matsumoto (nicholas.matsumoto@cshs.org) - Hyunjun Choi (hyunjun.choi@cshs.org) - Gabriel Ketron (gabriel.ketron@cshs.org) - Miguel E. Hernandez (miguel.e.hernandez@cshs.org) - Jason Moore (moorejh28@gmail.com)

TPOT 的原始版本主要由宾夕法尼亚大学的以下人员开发: - Randal S. Olson (rso@randalolson.com) - Weixuan Fu (weixuanf@upenn.edu) - Daniel Angell (dpa34@drexel.edu) - Jason Moore (moorejh28@gmail.com) - 以及许多其他慷慨的开源贡献者

TPOT 是自由软件:您可以根据自由软件基金会发布的 GNU 宽通用公共许可证(本许可证的第 3 版或(由您选择)任何后续版本)的条款重新分发和/或修改它。

分发 TPOT 是希望它会有用,但没有任何担保;甚至不包括适销性或特定用途适用性的默示担保。详情请参见 GNU 宽通用公共许可证。

您应该已随 TPOT 收到了 GNU 宽通用公共许可证的副本。如果未收到,请参阅 https://gnu.ac.cn/licenses/

is_pareto_efficient(scores, return_mask=True)

查找帕累托最优(pareto-efficient)点 :param scores: 一个 (n_points, n_scores) 数组 :param return_mask: 为 True 则返回掩码 :return: 一个帕累托最优点的索引数组。如果 return_mask 为 True,则这将是一个 (n_points, ) 布尔数组,否则将是一个 (n_efficient_points, ) 整型索引数组。

源代码位于 tpot/utils/utils.py
def is_pareto_efficient(scores, return_mask = True):
    """
    Find the pareto-efficient points
    :param scores: An (n_points, n_scores) array
    :param return_mask: True to return a mask
    :return: An array of indices of pareto-efficient points.
        If return_mask is True, this will be an (n_points, ) boolean array
        Otherwise it will be a (n_efficient_points, ) integer array of indices.
    """
    is_efficient = np.arange(scores.shape[0])
    n_points = scores.shape[0]
    next_point_index = 0  # Next index in the is_efficient array to search for
    while next_point_index<len(scores):
        nondominated_point_mask = np.any(scores>scores[next_point_index], axis=1)
        nondominated_point_mask[next_point_index] = True
        is_efficient = is_efficient[nondominated_point_mask]  # Remove dominated points
        scores = scores[nondominated_point_mask]
        next_point_index = np.sum(nondominated_point_mask[:next_point_index])+1
    if return_mask:
        is_efficient_mask = np.zeros(n_points, dtype = bool)
        is_efficient_mask[is_efficient] = True
        return is_efficient_mask
    else:
        return is_efficient