A machine learning-powered web application that predicts fight outcomes between One Piece characters using their combat statistics and abilities.
- ⚔️ Fight Prediction: Predict outcomes between any 2 One Piece characters in the top 100 One Piece Popularity Poll in 2021
- 🤖 ML-Powered: Uses Support Vector Machine with 96.26% accuracy
- 📊 Character Database: 100+ One Piece characters with detailed combat stats
- 🎨 Interactive UI: Streamlit web interface
- 🚀 Real-time API: FastAPI backend deployed on Railway
- 📱 Responsive Design: Works on desktop and mobile devices
- 🌐 Web App: One Piece Match Predictor
- 🔗 API Docs: FastAPI Documentation
- ❤️ Health Check: API Status
┌─────────────────┐ HTTP ┌──────────────────┐ ML Model ┌─────────────────┐
│ Streamlit │ ◄────────► │ FastAPI │ ◄─────────────► │ SVM Model │
│ Frontend │ │ Backend │ │ + Scaler │
│ (UI/UX) │ │ (API) │ │ + Encoder │
└─────────────────┘ └──────────────────┘ └─────────────────┘
│ │ │
│ │ │
Streamlit Railway Model Files
Cloud Deployment (.pkl format)
- Streamlit - Interactive web interface
- Pandas - Data manipulation
- Requests - API communication
- PIL - Image processing
- FastAPI - Modern Python web framework
- Uvicorn - Asynchronous Server Gateway Interface server
- Pydantic - Data validation
- CORS Middleware - Cross-origin requests
- Scikit-learn - SVM model and preprocessing
- NumPy - Numerical computations
- Pandas - Data analysis
- Joblib - Model serialization
- Railway - Backend API hosting
- Streamlit Cloud - Frontend hosting
- GitHub - Version control and CI/CD
Simply visit the live web app and start predicting fights!
- Python 3.8+
- Git
-
Clone the repository
git clone https://github.com/yourusername/one-piece-match-predictors.git cd one-piece-match-predictors -
Create a virtual environment
python -m venv venv # Windows venv\Scripts\activate # macOS/Linux source venv/bin/activate
-
Install dependencies
# Full development environment pip install -r requirements.txt
-
Start the FastAPI backend
python -m uvicorn src.api.main:app --reload --port 8000
-
Start the Streamlit frontend (in a new terminal)
streamlit run src/frontend/streamlit_app.py
-
Open your browser
- Frontend: http://localhost:8501
- API Docs: http://localhost:8000/docs
- Health Check: http://localhost:8000/health
one-piece-match-predictors/
├── 📁 src/
│ ├── 📁 api/
│ │ └── 📄 main.py # FastAPI application
│ ├── 📁 frontend/
│ │ └── 📄 streamlit_app.py # Streamlit web interface
│ ├── 📁 models/
│ │ ├── 📄 svm_fight_predictor.pkl # Trained ML model
│ │ ├── 📄 feature_scaler.pkl # Feature scaler
│ │ └── 📄 label_encoder.pkl # Label encoder
│ ├── 📁 data/
│ │ └── 📁 processed/
│ │ ├── 📄 character_data_cleaned.csv # Character database
│ │ └── 📄 fight_data_cleaned.csv # Simulated fights database
│ └── 📁 scraping/
│ └── 📄 scraper.py # Data collection scripts
├── 📄 requirements.txt # Full dependencies
├── 📄 railway.toml # Railway deployment config
├── 📄 .dockerignore # Docker ignore patterns
├── 📄 .gitignore # Git ignore patterns
└── 📄 README.md # This file
- Algorithm: Support Vector Machine (SVM)
- Accuracy: 96.26% on test data
- Features: 12 engineered features
- Classes: Victory, Loss, Draw
The model uses difference-based features between fighters:
- Base Stats Differences (10 features):
- Reaction Speed, Stamina, Strength, Offense, Defense
- Combat Skills, Battle IQ, Armament Haki, Observation Haki, Experience
- Conqueror's Haki Features (2 features):
- Presence indicator and difference impact
- 100+ One Piece characters with detailed combat statistics
- Dataset across victory/loss/draw outcomes
- Feature scaling using StandardScaler
- Label encoding for categorical outcomes
GET /healthReturns API status and model availability.
POST /predictPredicts fight outcome between two characters.
Request Body:
{
"fighter_1": {
"reaction_speed": 85,
"stamina": 90,
"strength": 95,
"offense": 88,
"defense": 82,
"combat_skills": 92,
"battle_iq": 85,
"armament_haki": 80,
"observation_haki": 75,
"conqueror_haki": 90,
"experience": 88
},
"fighter_2": {
"reaction_speed": 78,
"stamina": 85,
"strength": 82,
"offense": 80,
"defense": 88,
"combat_skills": 85,
"battle_iq": 90,
"armament_haki": 85,
"observation_haki": 88,
"conqueror_haki": 0,
"experience": 85
}
}Response:
{
"prediction": "victory",
"confidence": 0.87,
"probabilities": {
"victory": 0.87,
"loss": 0.10,
"draw": 0.03
},
"fighter_1_advantage": {
"reaction_speed": 7,
"stamina": 5,
"strength": 13,
...
},
"summary": "Fighter 1 wins with 87.0% confidence"
}GET /model/infoReturns model metadata and performance metrics.
GET /exampleReturns example fighter stats for testing.
The FastAPI backend is automatically deployed to Railway on every push to the main branch.
Environment Variables:
PORT: Automatically set by RailwayNIXPACKS_PYTHON_VERSION: Set to 3.11
The Streamlit frontend is deployed on Streamlit Cloud and automatically updates from GitHub.
GitHub Push → Railway Build → Health Check → Live Deployment ✅
→ Streamlit Cloud Build → Live Frontend ✅
The application includes 100+ One Piece characters with stats including:
- Physical Stats: Reaction Speed, Stamina, Strength
- Combat Stats: Offense, Defense, Combat Skills, Battle IQ
- Haki Abilities: Armament, Observation, Conqueror's Haki
- Experience: Overall battle experience
Popular characters include:
- Monkey D. Luffy, Roronoa Zoro, Sanji
- Kaido, Big Mom, Whitebeard
- Admiral Akainu, Kizaru, Aokiji
- And many more!
Contributions are welcome! Here's how to get started:
- Fork the repository
- Create a feature branch
git checkout -b feature/amazing-feature
- Make your changes
- Add tests (if applicable)
- Commit your changes
git commit -m "Add amazing feature" - Push to your branch
git push origin feature/amazing-feature
- Open a Pull Request
- 🎨 UI/UX improvements
- 📊 Additional character data
- 🤖 Model enhancements
- 📝 Documentation
This project is licensed under the MIT License - see the LICENSE file for details.
- Eiichiro Oda - Creator of One Piece
- One Piece Community - For character data and inspiration
