<jupyter_start><jupyter_text>Sci-Kit Learn Train Test Split [ Link ]<jupyter_code>from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.4)
X_train.shape
X_test.shape<jupyter_output><empty_output><jupyter_text>Sci-Kit Learn Random Forest Regressor [Link]<jupyter_code>from sklearn.ensemble import RandomForestRegressor
regressor = RandomForestRegressor(
    n_estimators=100,
    criterion='mse',
    max_depth=None,
    min_samples_split=2,
    min_samples_leaf=1,
    min_weight_fraction_leaf=0.0,
    max_features='auto',
    max_leaf_nodes=None,
    min_impurity_decrease=0.0,
    min_impurity_split=None,
    bootstrap=True,
    oob_score=True,
    n_jobs=16,
    random_state=None,
    verbose=1,
    warm_start=False)
regressor.fit(X_train, y_train)
regressor.score(X_test, y_test)
regressor.feature_importances_
y_test.head()
y_predicted = regressor.predict(X_test)
y_predicted
fig, ax = plt.subplots()

fig.subplots_adjust(bottom=0.3)

fig.set_figwidth(16)
fig.set_figheight(8)

ax.plot(y_test.index, y_test['40d'], 'ro')
ax.plot(y_test.index, y_predicted[:, 7], 'bo')

ax.legend()

plt.xticks(rotation=70)
plt.tight_layout()
plt.show();
from joblib import dump
dump(regressor, 'rf_regressor.joblib')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11782708492731446, 'fraction_numerical': 0.018362662586074982, 'mean_word_length': 6.307262569832402, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '485189', 'license': 'MIT', 'n_tokens_mistral': 550, 'n_tokens_neox': 520, 'n_words': 77, 'path': 'section_0002/SEC002 VID002 Build and Implement Random Forests Algorithm.ipynb', 'repo_name': 'narun4sk/Machine.Learning.for.Algorithmic.Trading.Bots', 'size': '1307'}