File size: 379 Bytes
e93c178
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
from sklearn.ensemble import RandomForestClassifier

def train_model(X, y):

    # just in case Loan_ID is still present, remove it
    if "Loan_ID" in X.columns:
        X = X.drop("Loan_ID", axis=1)

    # create Random Forest model
    model = RandomForestClassifier(n_estimators=200, max_depth=10, random_state=42)

    # train the model
    model.fit(X, y)

    return model