def run_model(X_train, y_train, X_valid, y_valid, X_test, categorical_features, predictors, maxvalue_dict, fold_id, params, model_name):
    train = lgb.Dataset(X_train, y_train, categorical_feature=categorical_features, feature_name=predictors)
    valid = lgb.Dataset(X_valid, y_valid, categorical_feature=categorical_features, feature_name=predictors)
    evals_result = {}
    model = lgb.train(params, train, valid_sets=[valid], valid_names=['valid'], evals_result=evals_result, **FIT_PARAMS)
    logger.info(f'Best Iteration: {model.best_iteration}')
    y_pred_train = model.predict(X_train)
    train_rmse = np.sqrt(mean_squared_error(y_train, y_pred_train))
    y_pred_valid = model.predict(X_valid)
    valid_rmse = np.sqrt(mean_squared_error(y_valid, y_pred_valid))
    y_pred_valid = (rankdata(y_pred_valid) / len(y_pred_valid))
    model.save_model(f'{model_name}_fold{fold_id}.txt')
    y_pred_test = model.predict(X_test)
    y_pred_test = (rankdata(y_pred_test) / len(y_pred_test))
    np.save(f'{model_name}_train_fold{fold_id}.npy', y_pred_valid)
    np.save(f'{model_name}_test_fold{fold_id}.npy', y_pred_test)
    return (y_pred_valid, y_pred_test, train_rmse, valid_rmse)
def run_model(X_train, y_train, X_valid, y_valid, X_test, categorical_features, predictors, maxvalue_dict, fold_id, params, model_name):
    train = lgb.Dataset(X_train, y_train, categorical_feature=categorical_features, feature_name=predictors)
    valid = lgb.Dataset(X_valid, y_valid, categorical_feature=categorical_features, feature_name=predictors)
    evals_result = {}
    model = lgb.train(params, train, valid_sets=[valid], valid_names=['valid'], evals_result=evals_result, **FIT_PARAMS)
    logger.info(f'Best Iteration: {model.best_iteration}')
    y_pred_train = model.predict(X_train)
    train_rmse = np.sqrt(mean_squared_error(y_train, y_pred_train))
    y_pred_valid = model.predict(X_valid)
    valid_rmse = np.sqrt(mean_squared_error(y_valid, y_pred_valid))
    y_pred_valid = (rankdata(y_pred_valid) / len(y_pred_valid))
    model.save_model(f'{model_name}_fold{fold_id}.txt')
    y_pred_test = model.predict(X_test)
    y_pred_test = (rankdata(y_pred_test) / len(y_pred_test))
    np.save(f'{model_name}_train_fold{fold_id}.npy', y_pred_valid)
    np.save(f'{model_name}_test_fold{fold_id}.npy', y_pred_test)
    return (y_pred_valid, y_pred_test, train_rmse, valid_rmse)