kaggle – What is the purpose of using get_n_splits instead of an integer value?

n_folds = 5

def rmsle(model):
    kf = KFold(n_folds, shuffle=True, random_state=42).get_n_splits(train.values)
    rmse = np.sqrt(-cross_val_score(model, train.values, y_train, scoring="neg_mean_squared_error", cv = kf))
    return(rmse)

I’m new to kaggle, and got stuck in this code.

I found out that get_n_splits returns the number of split data batches.
Then, what is the difference of just using the code

n_folds = 5

def rmsle(model):
    rmse = np.sqrt(-cross_val_score(model, train.values, y_train, scoring="neg_mean_squared_error", cv = 5))
    return(rmse)

as above?

I know that there was a question which asked exactly the same thing, but I’m not a native English speaker so couldn’t understand it clearly.
Can someone give me a good reason for this?

Read more here: Source link