<jupyter_start><jupyter_text><jupyter_code>from sklearn.ensemble import RandomForestRegressor
import numpy as np
import pandas as pd
from google.colab import drive
drive.mount('/content/drive')
df = pd.read_csv('/content/drive/Shareddrives/A-ICE/Data/AIS+ICE/winter_dataset.csv')
def mean_error(y_test, pred):
    return np.mean(np.abs(pred-y_test))
errors = []
importance = []
mmsis = df.mmsi.unique()
for mmsi in mmsis:
    train_set = df.loc[df.mmsi==mmsi]
    test_set = df.loc[df.mmsi!=mmsi]
    x_train = train_set[['wind_hailuoto','temperature_hailuoto', 'ice_thickness', 'ice_concentration']]
    x_test = test_set[['wind_hailuoto', 'temperature_hailuoto', 'ice_thickness', 'ice_concentration']]
    y_train = train_set['speed']
    y_test = test_set['speed']
    y_train = np.ravel(y_train)
    model = RandomForestRegressor()
    model.fit(x_train, y_train)
    prediction = model.predict(x_test)
    errors.append([mean_error(y_test,prediction)])
    importance.append(model.feature_importances_)


print(errors)
print(importance)
import matplotlib.pyplot as plt

plt.pcolormesh(importance)
plt.colorbar()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13263525305410123, 'fraction_numerical': 0.0, 'mean_word_length': 5.747058823529412, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '322293', 'license': 'MIT', 'n_tokens_mistral': 449, 'n_tokens_neox': 435, 'n_words': 67, 'path': 'notebooks/RandomForestDEMO.ipynb', 'repo_name': 'elguitar/a-ice', 'size': '1146'}