examples/feat_import.py
def tree_import(sim_name):
    """Train a random forest for a given simulation, calculate feature importance."""
    # simulate data
    x, y = SIMULATIONS[sim_name](SIM_SIZE, DIM)
    if y.shape[1] == 1:
        y = y.ravel()

    with warnings.catch_warnings():
        # get feature importances
        _, _, importances = KMERF(forest="regressor", ntrees=FOREST_SIZE).test(
            x, y, reps=0
        )

    return importances
Train a random forest for a given simulation, calculate feature importance.
Train a random forest for a given simulation, calculate feature importance.
Train a random forest for a given simulation calculate feature importance .
def tree_import(sim_name):
    x, y = SIMULATIONS[sim_name](SIM_SIZE, DIM)
    if y.shape[1] == 1:
        y = y.ravel()
    with warnings.catch_warnings():
        _, _, importances = KMERF(forest="regressor", ntrees=FOREST_SIZE).test(
            x, y, reps=0
        )
    return importances
def tree_import ( sim_name ) : x , y = SIMULATIONS [ sim_name ] ( SIM_SIZE , DIM ) if y . shape [ 1 ] == 1 : y = y . ravel ( ) with warnings . catch_warnings ( ) : _ , _ , importances = KMERF ( forest = "regressor" , ntrees = FOREST_SIZE ) . test ( x , y , reps = 0 ) return importances
Train a random forest for a given simulation, calculate feature importance.
Train a random forest for a given simulation calculate feature importance .
"""Train a random forest for a given simulation, calculate feature importance.""" # simulate data # get feature importances
sim_name