Predicting which Ronin blockchain users will remain active based on their historical transaction behavior using Machine Learning.
- Problem Description
- Dataset
- Project Structure
- Features
- Model Performance
- Results
- Installation
- Usage
- API Documentation
- Docker Deployment
- Technologies Used
Identifying which blockchain users will remain active vs churn is critical for:
- User retention strategies - Focus resources on at-risk users
- Community growth - Understand what drives engagement
- Resource allocation - Prioritize high-value, consistent users
Binary Classification: Predict if a user will be active (5+ transactions) in the next 90 days based on their past 365 days of behavior.
Target Variable:
Good Trader(1): User with β₯5 transactions in next 90 daysBad Trader(0): User with <5 transactions in next 90 days
- Blockchain: Ronin Network
- Platform: Dune Analytics - Query ID 6221750
- Time Period:
- Training: 455 days ago β 90 days ago (365-day window)
- Prediction: Last 90 days
- Total Records: 5,000 users
- Class Distribution: Perfectly balanced (2,500 Good, 2,500 Bad)
| Feature | Description | Type |
|---|---|---|
tx_count_365d |
Total transactions in past 365 days | Integer |
total_volume |
Total transaction volume in USD | Float |
active_weeks |
Number of weeks user was active | Integer |
avg_tx_value |
Average value per transaction | Float |
tx_per_active_week |
Transactions per active week | Float |
ronin-users-classification/
βββ data/
β βββ ronin_traders_dataset.csv # Training dataset
βββ notebooks/
β βββ 01_eda_and_training.ipynb # EDA & model training
βββ models/
β βββ best_model_random_forest.pkl # Trained model
β βββ feature_names.pkl # Feature names
β βββ model_comparison_results.csv # Performance metrics
βββ visualizations/
β βββ eda_analysis.png # EDA visualizations
β βββ model_comparison.png # Model performance
β βββ confusion_matrix.png # Confusion matrix
β βββ feature_importance.png # Feature importance
βββ src/
β βββ predict.py # Prediction script
β βββ app.py # Flask API
β βββ test_api.py # API tests
βββ Dockerfile # Docker configuration
βββ requirements.txt # Python dependencies
βββ README.md # This file
- tx_count_365d - Transaction frequency indicator
- total_volume - Economic activity measure
- active_weeks - Consistency/engagement metric
- avg_tx_value - Transaction size indicator
- tx_per_active_week - Activity intensity measure
| Feature | Importance | Interpretation |
|---|---|---|
| total_volume | 30% | π° Most critical factor |
| active_weeks | 28% | π Consistency matters |
| tx_count_365d | 22% | π’ Activity level important |
| avg_tx_value | 11% | π΅ Transaction size relevant |
| tx_per_active_week | 9% | β‘ Frequency moderately important |
- Random Forest β (Best)
- XGBoost
- Decision Tree
- Logistic Regression
| Metric | Score | Interpretation |
|---|---|---|
| ROC-AUC | 0.9646 | Outstanding discriminative ability |
| Accuracy | 91.4% | Correct 914/1000 predictions |
| Precision | 90.4% | 90.4% of "Good" predictions are correct |
| Recall | 92.6% | Catches 92.6% of actual good traders |
| F1-Score | 91.5% | Balanced precision/recall |
| Predicted Bad | Predicted Good | |
|---|---|---|
| Actual Bad | 451 β | 49 β |
| Actual Good | 37 β | 463 β |
Key Insight: Only 86 misclassifications out of 1,000 test samples (8.6% error rate)
| Model | Accuracy | ROC-AUC |
|---|---|---|
| Random Forest | 91.4% | 0.9646 |
| XGBoost | 90.4% | 0.9619 |
| Decision Tree | 87.8% | 0.9468 |
| Logistic Regression | 83.0% | 0.8889 |
π Results ---> Check RESULTS.md for full details
-
Transaction volume is the strongest predictor (30% importance)
- Higher volume β Higher retention
-
Consistency matters more than intensity
- Active weeks (28%) > Transactions per week (9%)
-
Model achieves 96.46% ROC-AUC
- Production-ready performance
- Balanced precision and recall
- Churn Prediction: Identify 92.6% of users at risk of leaving
- Resource Optimization: Focus retention efforts on predicted churners
- Early Warning: 90-day advance notice for intervention
- Accuracy: 91.4% correct predictions
- Python 3.10+
- pip or conda
- Docker (optional, for containerization)
- Clone the repository
git clone https://github.com/yourusername/ronin-trader-classification.git
cd ronin-trader-classification- Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies
pip install -r requirements.txt- Verify installation
python predict.pyfrom predict import RoninTraderPredictor
# Initialize predictor
predictor = RoninTraderPredictor()
# Single prediction
trader = {
'tx_count_365d': 150,
'total_volume': 25.5,
'active_weeks': 20,
'avg_tx_value': 0.17,
'tx_per_active_week': 7.5
}
result = predictor.predict_single(trader)
print(f"Prediction: {result['prediction']}")
print(f"Confidence: {result['confidence']:.2%}")Run the example:
python predict.pyStart the API:
python app.pyAPI will be available at http://localhost:5000
python test_api.pyhttp://localhost:5000
Get API information
Response:
{
"service": "Ronin Trader Classification API",
"version": "1.0",
"model": "Random Forest",
"model_performance": {
"accuracy": "91.4%",
"roc_auc": "0.9646"
}
}Check service status
Response:
{
"status": "healthy",
"model_loaded": true,
"features_loaded": true
}Get required feature information
Response:
{
"required_features": ["tx_count_365d", "total_volume", ...],
"descriptions": {...},
"example": {...}
}Request:
curl -X POST http://localhost:5000/predict \
-H "Content-Type: application/json" \
-d '{
"tx_count_365d": 150,
"total_volume": 25.5,
"active_weeks": 20,
"avg_tx_value": 0.17,
"tx_per_active_week": 7.5
}'Response:
{
"prediction": "Good Trader",
"will_remain_active": true,
"confidence": 0.92,
"probability_good_trader": 0.92,
"probability_bad_trader": 0.08,
"input_features": {...}
}Request:
curl -X POST http://localhost:5000/predict_batch \
-H "Content-Type: application/json" \
-d '{
"traders": [
{"tx_count_365d": 500, "total_volume": 100.0, ...},
{"tx_count_365d": 10, "total_volume": 0.5, ...}
]
}'Response:
{
"predictions": [
{
"index": 0,
"prediction": "Good Trader",
"confidence": 0.95,
...
}
],
"summary": {
"total": 2,
"good_traders": 1,
"bad_traders": 1,
"percentage_good": 50.0
}
}docker build -t ronin-trader-classifier .docker run -p 5000:5000 ronin-trader-classifiercurl http://localhost:5000/healthCreate docker-compose.yml:
version: '3.8'
services:
api:
build: .
ports:
- "5000:5000"
environment:
- PORT=5000
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:5000/health"]
interval: 30s
timeout: 3s
retries: 3Run with:
docker-compose up- Python 3.10 - Programming language
- Pandas & NumPy - Data manipulation
- Scikit-learn - Machine learning
- XGBoost - Gradient boosting
- Flask - Web framework
- Docker - Containerization
- Dune Analytics - Blockchain data
- Jupyter - Interactive development
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Submit a pull request
- X: @defi__josh
- LinkedIn: Joshua Nwachukwu
- Telegram: @joshuatochinwachi
- Email: joshuatochinwachi@gmail.com
- DataTalksClub - ML Zoomcamp course
- Dune Analytics - Blockchain data platform
- Ronin Network - Blockchain infrastructure
- Sky Mavis - Ronin creators
Built with β€οΈ for the Ronin Community