src/models/param_tuning.py
def main(train_path, cv_idx_path,
         num_eval=100):
    """"Search for optimal parameters using hyperopt and write
    to params.yml in root dir"""

    # read files
    train_df, cv_idx = load_data([train_path, cv_idx_path],
                                 sep=",", header=0,
                                 index_col="PassengerId")

    # load params
    params = load_params()
    classifier = params["classifier"]
    target_class = params["train_test_split"]["target_class"]

    # get independent variables (features) and
    # dependent variables (labels)
    train_feats = train_df.drop(target_class, axis=1)
    train_labels = train_df[target_class]

    # find optimal parameters for a specific model
    if classifier.lower() == "random_forest":
        best_params = rf_model(train_feats.to_numpy(),
                               train_labels.to_numpy(),
                               random_state=params["random_seed"],
                               num_eval=num_eval)  # cv=split_generator
    else:
        raise NotImplementedError

    # update params
    params["model_params"][classifier] = best_params

    # save
    save_params(params)
Search for optimal parameters using hyperopt and write
    to params.yml in root dir
Search for optimal parameters using hyperopt and write
to params.yml in root dir
Search for optimal parameters using hyperopt and write to params . yml in root dir
def main(train_path, cv_idx_path,
         num_eval=100):
    train_df, cv_idx = load_data([train_path, cv_idx_path],
                                 sep=",", header=0,
                                 index_col="PassengerId")
    params = load_params()
    classifier = params["classifier"]
    target_class = params["train_test_split"]["target_class"]
    train_feats = train_df.drop(target_class, axis=1)
    train_labels = train_df[target_class]
    if classifier.lower() == "random_forest":
        best_params = rf_model(train_feats.to_numpy(),
                               train_labels.to_numpy(),
                               random_state=params["random_seed"],
                               num_eval=num_eval)  
    else:
        raise NotImplementedError
    params["model_params"][classifier] = best_params
    save_params(params)
def main ( train_path , cv_idx_path , num_eval = 100 ) : train_df , cv_idx = load_data ( [ train_path , cv_idx_path ] , sep = "," , header = 0 , index_col = "PassengerId" ) params = load_params ( ) classifier = params [ "classifier" ] target_class = params [ "train_test_split" ] [ "target_class" ] train_feats = train_df . drop ( target_class , axis = 1 ) train_labels = train_df [ target_class ] if classifier . lower ( ) == "random_forest" : best_params = rf_model ( train_feats . to_numpy ( ) , train_labels . to_numpy ( ) , random_state = params [ "random_seed" ] , num_eval = num_eval ) else : raise NotImplementedError params [ "model_params" ] [ classifier ] = best_params save_params ( params )
Search for optimal parameters using hyperopt and write
to params.yml in root dir
Search for optimal parameters using hyperopt and write to params . yml in root dir
""""Search for optimal parameters using hyperopt and write
    to params.yml in root dir""" # read files # load params # get independent variables (features) and # dependent variables (labels) # find optimal parameters for a specific model # cv=split_generator # update params # save
train_path
cv_idx_path
num_eval