--- license: mit --- # FinML-Chain: A Blockchain-Integrated Dataset for Enhanced Financial Machine Learning ## Table of Contents - Data - Code - Result - Reference ## Data #### Collection for On-chain Data We collect the data through BigQuery, and the code we used is in [Query](https://huggingface.co/datasets/dkublockchain/FinML_Chain/blob/main/data/DataQuery.txt) [Code for querying data](./data/DataQuery.txt) You can also refer to [BigQuery](https://console.cloud.google.com/bigquery?p=bigquery-public-data&d=crypto_ethereum_classic&page=dataset&project=psyched-service-412017&ws=!1m9!1m4!4m3!1sbigquery-public-data!2sethereum_blockchain!3slive_blocks!1m3!3m2!1sbigquery-public-data!2scrypto_ethereum_classic&pli=1) for more information. #### Collection for Off-chain Data ### On-chain Data Infomation | Data Files | Data Type | Data Content | | ------------- | ------------- | ------------- | | [ETH-Token-airdrop.csv](https://huggingface.co/datasets/dkublockchain/FinML_Chain/blob/main/data/eth-onchain-03%3A2023_04%3A2023.csv) | Raw Data | Critical indicators related to gas during tokrn airdrop period | | [ETH-Normal.csv](https://huggingface.co/datasets/dkublockchain/FinML_Chain/blob/main/data/eth-onchain-06%3A2023-07%3A2023.csv) | Raw Data | Critical indicators related to gas during normal period | #### On chain Data Dictionary - **ETH-Token-airdrop.csv and ETH-Normal.csv** | Variable Name | Description | Type | |------------------------|-----------------------------------|---------| | timestamp | Recoding of the time of each block| String | | number | The number of blocks on the chain | Numeric | | gas_used | Actual gas used | Numeric | | gas_limit | The maximum allowed gas per block | Numeric | | base_fee_per_gas | The base fee set for each block | Numeric | - **Additional Variables we create** | Variable Name | Description | Type | |------------------------|-----------------------------------|---------| | gas_fraction | Fraction between Gas Used and Gas Limit | Numeric | | gas_target | The optimal gas used for each block | Numeric | | Y | Normalized Gas Used | Numeric | | Yt | Response variable equals to the gas_fraction| Numeric | ### Off-chain Data Information | Variable Name | Description | Type | |------------------------|-----------------------------------|---------| | chat text | people's chat (sentences) | String | ## Code | Code Files | Code Description | | ------------- | ------------- | | [main_dataset_processing_code.ipynb](https://huggingface.co/datasets/dkublockchain/FinML_Chain/blob/main/code/main_dataset_processing_code.ipynb) | Applying FinBert to process discord information; Applying the NAM model to manipulate monotonicity; Applying Both on-chain data and off-chain data to train the model | [NAM models.py](https://huggingface.co/datasets/dkublockchain/FinML_Chain/blob/main/code/NAM_models.py) | NAM model | [baseline_dataset_processing_code.ipynb](https://huggingface.co/datasets/dkublockchain/FinML_Chain/blob/main/code/baseline_dataset_processing_code.ipynb) | Using linear algorithm, DNN, XGBoost and long-short term memory to predict gas used. ## Results ### Baseline results
Baseline loss for Token-airdrop period dex-to-cex Baseline loss for Token-airdrop period
Baseline variance for Token-airdrop period dex-to-cex Baseline variance for Token-airdrop period
Baseline loss for normal period dex-to-cex Baseline loss for normal period
Baseline variance for normal period dex-to-cex Baseline variance for normal period
### Flow chart
Flow chart of combination of Off-chain and On-chain dex-to-cex Flow chart of combination of Off-chain and On-chain
### Monotonicity Two-step training loss (normal training and monotonic training) We utilized the NAM model due to its inherent transparency characteristic and the ability to isolate variables, facilitating the imposition of monotonicity constraints on specific features. The model is trained on data from two distinct periods, achieving weak pairwise monotonicity over the $\alpha$ feature. In the first step, standard training is conducted to enable the model to learn from the data. In the second step, we impose monotonic constraints.
Two-step training loss Two-step training loss
### Sentiment (Combination of Off-chain and On-chain) We further explore the NAM model at k=1,2 and 3. Given the availability of both on-chain and off-chain variables, we conducted tests to determine whether the inclusion of off-chain variables, specifically sentiment analysis, enhances the model's predictability.

Model Performance over Two Periods

Model Performance over Two Periods
+OC,+DS,+HS +OC,+DS,-HS +OC,-DS,+HS +OC,-DS,-HS
Period 1: 03/21/2023 - 04/01/2023 (ARB-airdrop)
3 Timesteps 0.10022 0.10150 0.10164 0.10201
2 Timesteps 0.10056 0.10249 0.10213 0.10265
1 Timestep 0.10169 0.10190 0.10204 0.10290
Period 2: 06/01/2023 - 07/01/2023 (Normal)
3 Timesteps 0.13341 0.15657 0.16142 0.16089
2 Timesteps 0.13477 0.15381 0.15806 0.16456
1 Timestep 0.13593 0.15321 0.15459 0.18428

The notation "OC" refers to On-chain variables, while "HS" and "DS" denote Hourly Averaged Sentiment and Daily Averaged Sentiment, respectively. The ‘+’ symbol indicates the inclusion of a variable in the model, whereas the ‘-’ symbol denotes its exclusion. The numerical values represent the mean square error (MSE) of the model on the test dataset.