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
