Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

28 Commits

Folders and files

Repository files navigation

βš”οΈ One Piece Match Predictor

A machine learning-powered web application that predicts fight outcomes between One Piece characters using their combat statistics and abilities.

One Piece Banner

🌟 Features

  • βš”οΈ 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

🎯 Live Demo

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    HTTP    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    ML Model    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Streamlit     β”‚ ◄────────► β”‚   FastAPI        β”‚ ◄─────────────► β”‚   SVM Model     β”‚
β”‚   Frontend      β”‚            β”‚   Backend        β”‚                β”‚   + Scaler      β”‚
β”‚   (UI/UX)       β”‚            β”‚   (API)          β”‚                β”‚   + Encoder     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜            β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
      β”‚                               β”‚                                     β”‚
      β”‚                               β”‚                                     β”‚
   Streamlit                       Railway                              Model Files
   Cloud                          Deployment                           (.pkl format)

πŸ› οΈ Tech Stack

Frontend

  • Streamlit - Interactive web interface
  • Pandas - Data manipulation
  • Requests - API communication
  • PIL - Image processing

Backend

  • FastAPI - Modern Python web framework
  • Uvicorn - Asynchronous Server Gateway Interface server
  • Pydantic - Data validation
  • CORS Middleware - Cross-origin requests

Machine Learning

  • Scikit-learn - SVM model and preprocessing
  • NumPy - Numerical computations
  • Pandas - Data analysis
  • Joblib - Model serialization

Deployment

  • Railway - Backend API hosting
  • Streamlit Cloud - Frontend hosting
  • GitHub - Version control and CI/CD

πŸš€ Quick Start

Option 1: Use the Live App (Recommended)

Simply visit the live web app and start predicting fights!

Option 2: Local Development

Prerequisites

  • Python 3.8+
  • Git

Installation

  1. Clone the repository

    git clone https://github.com/yourusername/one-piece-match-predictors.git
    cd one-piece-match-predictors
  2. Create a virtual environment

    python -m venv venv
    
    # Windows
    venv\Scripts\activate
    
    # macOS/Linux
    source venv/bin/activate
  3. Install dependencies

    # Full development environment
    pip install -r requirements.txt

Running Locally

  1. Start the FastAPI backend

    python -m uvicorn src.api.main:app --reload --port 8000
  2. Start the Streamlit frontend (in a new terminal)

    streamlit run src/frontend/streamlit_app.py
  3. Open your browser

πŸ“ Project Structure

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

πŸ€– Machine Learning Model

Model Details

  • Algorithm: Support Vector Machine (SVM)
  • Accuracy: 96.26% on test data
  • Features: 12 engineered features
  • Classes: Victory, Loss, Draw

Feature Engineering

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

Training Data

  • 100+ One Piece characters with detailed combat statistics
  • Dataset across victory/loss/draw outcomes
  • Feature scaling using StandardScaler
  • Label encoding for categorical outcomes

πŸ”— API Documentation

Endpoints

Health Check

GET /health

Returns API status and model availability.

Fight Prediction

POST /predict

Predicts 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"
}

Model Information

GET /model/info

Returns model metadata and performance metrics.

Example Request

GET /example

Returns example fighter stats for testing.

πŸš€ Deployment

Backend (Railway)

The FastAPI backend is automatically deployed to Railway on every push to the main branch.

Environment Variables:

  • PORT: Automatically set by Railway
  • NIXPACKS_PYTHON_VERSION: Set to 3.11

Frontend (Streamlit Cloud)

The Streamlit frontend is deployed on Streamlit Cloud and automatically updates from GitHub.

CI/CD Pipeline

GitHub Push β†’ Railway Build β†’ Health Check β†’ Live Deployment βœ…
            β†’ Streamlit Cloud Build β†’ Live Frontend βœ…

πŸ“Š Character Database

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!

🀝 Contributing

Contributions are welcome! Here's how to get started:

  1. Fork the repository
  2. Create a feature branch
    git checkout -b feature/amazing-feature
  3. Make your changes
  4. Add tests (if applicable)
  5. Commit your changes
    git commit -m "Add amazing feature"
  6. Push to your branch
    git push origin feature/amazing-feature
  7. Open a Pull Request

Areas for Contribution

  • 🎨 UI/UX improvements
  • πŸ“Š Additional character data
  • πŸ€– Model enhancements
  • πŸ“ Documentation

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

  • Eiichiro Oda - Creator of One Piece
  • One Piece Community - For character data and inspiration

πŸ΄β€β˜ οΈ Made with ❀️ for the One Piece community! πŸ΄β€β˜ οΈ

"I'm gonna be the King of the Pirates!" - Monkey D. Luffy

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages