<jupyter_start><jupyter_text>EDA<jupyter_code>df.shape
# Number of Unique Rounds in the data
df['confirmed-round'].nunique()
df.head(5)
df.columns
df['round-time'] = pd.to_datetime(df['round-time'], unit='s')
ag_df = df.groupby(by=[df['round-time'].dt.date])['asset-transfer-transaction.amount'].agg(volume='sum', mean='mean')
ag_df
fig = px.line(ag_df, y=ag_df.volume, x=ag_df.index)
fig.update_layout(template="plotly_dark")
fig.show()<jupyter_output><empty_output><jupyter_text>Feature Engineering<jupyter_code># inserting new column with yesterday's values
ag_df.loc[:,'volume-1'] = ag_df.loc[:,'volume'].shift()

# inserting another column with difference between yesterday and day before yesterday's consumption values.
ag_df.loc[:,'volume_diff'] = ag_df.loc[:,'volume'].diff()

ag_df
# dropping NAs
ag_df = ag_df.dropna()<jupyter_output><empty_output><jupyter_text>Defining Training and Testing Data<jupyter_code>train = ag_df[:int(len(ag_df)*0.8)]
test = ag_df[int(len(ag_df)*0.8):]

X_train, X_test, y_train, y_test = train.drop('volume', axis=1), test.drop('volume', axis=1), train['volume'], test['volume']<jupyter_output><empty_output><jupyter_text>Trainining Algorithm<jupyter_code>model = RandomForestRegressor(random_state=42)
param_search = { 
    'n_estimators': [10, 20, 50, 100],
    'max_features': ['auto', 'sqrt', 'log2'],
    'max_depth' : [i for i in range(1,15)]
}
tscv = TimeSeriesSplit(n_splits=4)
gsearch = GridSearchCV(estimator=model, cv=tscv, param_grid=param_search, scoring = 'neg_mean_squared_error')
gsearch.fit(X_train, y_train)
rf_best_score = gsearch.best_score_
rf_best_model = gsearch.best_estimator_
print(f"{rf_best_model} at {rf_best_score}")
model = MLPRegressor(random_state=1)
param_search = { 
    'max_iter':[ 100, 200, 400, 600, 800, 1000],
    'solver': ['lbfgs', 'sgd', 'adam'],
    'activation':['identity', 'logistic', 'tanh', 'relu'],
}

tscv = TimeSeriesSplit(n_splits=4)
gsearch = GridSearchCV(estimator=model, cv=tscv, param_grid=param_search, scoring = 'neg_mean_squared_error')
gsearch.fit(X_train, y_train)
best_score = gsearch.best_score_
best_model = gsearch.best_estimator_
print(f"{best_model} at {best_score}")<jupyter_output>MLPRegressor(activation='identity', max_iter=100, random_state=1,
             solver='lbfgs') at -0.01366814935876111<jupyter_text>Scoring<jupyter_code>def regression_results(y_true, y_pred):
    # Regression metrics
    explained_variance = metrics.explained_variance_score(y_true, y_pred)
    mean_absolute_error = metrics.mean_absolute_error(y_true, y_pred) 
    mse=metrics.mean_squared_error(y_true, y_pred) 
    mean_squared_log_error=metrics.mean_squared_log_error(y_true, y_pred)
    r2=metrics.r2_score(y_true, y_pred)
    
    print('explained_variance: ', round(explained_variance, 4))    
    print('mean_squared_log_error: ', round(mean_squared_log_error, 4))
    print('r2: ', round(r2, 4))
    print('MAE: ', round(mean_absolute_error, 4))
    print('MSE: ', round(mse, 4))
    print('RMSE: ', round(np.sqrt(mse), 4))
y_true = y_test.values
y_pred = best_model.predict(X_test)
regression_results(y_true, y_pred)
y_true = y_test.values
y_pred = rf_best_model.predict(X_test)
regression_results(y_true, y_pred)<jupyter_output>explained_variance:  0.8246
mean_squared_log_error:  0.4095
r2:  0.8123
MAE:  7158214.9641
MSE:  317670022535022.56
RMSE:  17823299.99
{'fraction_non_alphanumeric': 0.14829123328380386, 'fraction_numerical': 0.038930163447251115, 'mean_word_length': 7.169902912621359, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, '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': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '613073', 'license': 'MIT', 'n_tokens_mistral': 1422, 'n_tokens_neox': 1313, 'n_words': 202, 'path': 'algorand_solutions/Data.ipynb', 'repo_name': 'Pfed-prog/Algorand-ML-Broker', 'size': '3365'}