I have the following code that does a random forest regression to see feature importance. I would like to do cross validation or k-folds. Here is my code for doing the regression, which gives me the features and their ranks. I have attempted transforming some code I found online to add cross validation to it but have so far had no success. Any ideas? I am not dividing the data into test/train sets.
df = pd.read_csv(dataset_path + file_name)
X = df.drop(['target'], axis = 1)
y= df['target']
clf = RandomForestRegressor(random_state = 42, n_jobs=-1)
# Train model
model = clf.fit(X, y)
feat_importances = pd.DataFrame(model.feature_importances_, index = X.columns, columns=["Importance"])
feat_importances.sort_values(by='Importance', ascending=False, inplace=True)
feat_importances.plot(kind='bar', figsize=(8,6))