Skip to content

alejandro-delgado-t/API_model_test

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Machine Learning API

πŸ“Œ Overview

This repository contains an API that serves a Machine Learning model for predictions. The API is built using FastAPI and serves a pre-trained model stored in a pickle file. It receives input in JSON format, processes it, and returns predictions.

πŸš€ Features

  • Trains a Machine Learning model and serializes it using joblib
  • Provides an API endpoint to make predictions
  • Accepts JSON input for inference
  • Includes a sample .json file for testing
  • Supports API request handling via a separate script

πŸ“‚ Project Structure

πŸ“¦ ML_API_Repository
 ┣ πŸ“œ model.pkl                # Trained Machine Learning model
 ┣ πŸ“œ api.py                    # FastAPI implementation
 ┣ πŸ“œ request.py                # Script to send test requests to API
 ┣ πŸ“œ sample_input.json         # Example input file
 ┣ πŸ“œ requirements.txt          # List of dependencies
 β”— πŸ“œ README.md                 # This documentation file

πŸ›  Setup & Installation

  1. Clone the Repository
    git clone https://github.com/your-repo-name.git
    cd your-repo-name
  2. Create a Virtual Environment (Recommended)
    python -m venv venv
    source venv/bin/activate  # On Windows use: venv\Scripts\activate
  3. Install Dependencies
    pip install -r requirements.txt

πŸ“‘ Running the API

  1. Start the API Server

    uvicorn api:app --reload

    The API will run on localhost:8000

  2. Test the API (Use request.py or curl)

    python request.py

    OR

    curl -X POST "http://localhost:8000/predict" -H "Content-Type: application/json" -d @sample_input.json

πŸ“€ Making a Prediction Request

  • Example JSON input (sample_input.json):
    {
      "feature1": value1,
      "feature2": value2,
      "feature3": value3
    }
  • Example Response:
    {
      "prediction": "predicted_value"
    }

πŸ“œ Commit & Share

  1. Commit the necessary files:
    git add api.py model.pkl request.py sample_input.json README.md
    git commit -m "Initial commit - ML API setup"
    git push origin main
  2. Share the Repository:
    • Ensure the repository is accessible to the instructor (Icedgarr)
    • Submit the repository link as required

πŸ”— References

πŸ“Œ Notes

  • Ensure that the .pkl file is stored in the same directory as api.py
  • The API should be structured to handle errors gracefully
  • Modify request.py to test with different inputs

πŸš€ Happy coding!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages