コード例 #1
0
ファイル: ranking_util.py プロジェクト: JonasHanselle/CoRRAS
def construct_numpy_representation_with_ordered_pairs_of_rankings_and_features_and_weights(
        features: pd.DataFrame,
        performances: pd.DataFrame,
        max_pairs_per_instance=100,
        seed=1,
        order="asc",
        skip_value=None):
    """Get numpy representation of features, performances and rankings

    Arguments:
        features {pd.DataFrame} -- Feature values
        performances {pd.DataFrame} -- Performances of algorithms

    Returns:
        [type] -- Triple of numpy ndarrays, first stores the feature
        values, the second stores the algirhtm performances and the
        third stores the algorithm rankings
    """
    rankings, weights = sample_pairs(performances,
                                     pairs_per_instance=max_pairs_per_instance,
                                     seed=seed,
                                     skip_value=skip_value)
    joined = rankings.join(features).join(performances,
                                          lsuffix="_rank",
                                          rsuffix="_performance")
    np_features = joined[features.columns.values].values
    np_performances = joined[[x for x in performances.columns]].values
    np_rankings = joined[[x for x in rankings.columns]].values + 1
    np_performances = np_performances[
        np.arange(np_performances.shape[0])[:, np.newaxis], np_rankings - 1]
    max_len = len(performances.columns)
    print("performances", performances.head())
    print("labels", rankings.head())
    print("weight", weights.head())
    np_weights = weights.to_numpy()
    np_weights = np.amax(np_weights, axis=1)
    # print("np_weights", np_weights)
    np_weights = np.exp2(np_weights)
    # print("exp np_weights", np_weights)

    # TODO check for maximization problems
    if order == "desc":
        np_rankings = np.flip(np_rankings, axis=1)
        np_performances = np.flip(np_performances, axis=1)

    return np_features, np_performances, np_rankings, np_weights
コード例 #2
0
ファイル: test_scalar_ops.py プロジェクト: zaxtax/autograd
def test_exp2():
    fun = lambda x : 3.0 * np.exp2(x)
    d_fun = grad(fun)
    check_grads(fun, abs(npr.randn()))
    check_grads(d_fun, abs(npr.randn()))
コード例 #3
0
def test_exp2():
    fun = lambda x : 3.0 * np.exp2(x)
    d_fun = grad(fun)
    check_grads(fun, abs(npr.randn()))
    check_grads(d_fun, abs(npr.randn()))
コード例 #4
0
def test_exp2():
    fun = lambda x: 3.0 * np.exp2(x)
    check_grads(fun)(abs(npr.randn()))
コード例 #5
0
ファイル: test_scalar_ops.py プロジェクト: HIPS/autograd
def test_exp2():
    fun = lambda x : 3.0 * np.exp2(x)
    check_grads(fun)(abs(npr.randn()))