Skip to content

kmadsdev/hivemind-ml-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 

Repository files navigation

HiveMind - Machine Learning API on AWS

API for the HiveMind's Machine Learning repository -> /kmadsdev/hivemind-ml.

Stack

  • Language: Python
  • Frameworks/Tools: FastAPI, Uvicorn, Boto3
  • Deploy: AWS (EC2 + S3)

Dependencies

  • FastAPI
  • Boto3
  • Uvicorn
  • Pydantic
  • Pathlib
  • Datetime

Pipeline - AWS configuration for the API:

Step 1 - Set up S3:

Upload the latest machine learning model file to a Bucket on S3

Note: the default bucket name on the code is 'hivemind-ml-models', and can be changed on app.py by changing the BUCKET variable.

Step 2 - Set up EC2:

  • Application OS: Amazon Linux (Prefered)
    • Architecture: 64-bit Arm (Prefered)
  • Intance type: t4g.small (or similar)
  • Network settings / Check all these:
    • Allow SSH traffic from Anywhere (0.0.0.0:0)
    • Allow HTTP traffic from the internet
    • Allow HTTPS traffic from the internet

Step 3 - Run app:

  • Inside EC2 (Amazon Linux)
    • Install python, pip and git: 'sudo yum install -y python pip git'
    • Install libs & requirements: 'pip install -r requirements.txt'
    • Clones git repository: 'git clone '
    • Check for updates: 'git pull'
    • Run app 'python3 hivemind-ml-api/app.py'

Step 4 - Set the host to public + set port to 8000

On your EC2 instance go to Network & Security > Security Groups
Press actions menu then Edit inbound rules > Add rule:

  • Type: Select the protocol (HTTP, HTTPS, Custom TCP, etc.)
  • Port range: set the port to 8000
  • Source: 0.0.0.0/0 Then click Save rules

Step 5 - Get the public IPv4 address:

EC2 > Instances > On the list select your Instance (click on Instance ID) > Details > Instance summary > Public IPv4 address > Copy the address

After that you will be able to acess the model using this URL: http://:8000/

Note: the url must be HTTP


Usage:

Url: http://<ec2-public-host>:<ec2-port>/predict?inputs='<inputs-here>'

  • Note: make sure you typed http, because it won't work if your try to use https
  • Inputs must be in the python's string format and be separated by commas (",") only

Example: http://1337.101.404:8000/predict?inputs='200,450,1,0,1,1,0,1,0.72418,271.48123'

Input list:

  1.   int
  2.   int
  3.   int (0 or 1)
  4.   int (0 or 1)
  5.   int (0 or 1)
  6.   int (0 or 1)
  7.   int (0 or 1)
  8.   int (0 or 1)
  9.   float (between 0.00001 and 1)
  10.   float (between 0 and 999.99999)

Update log

●   27 oct 2025   |   New Machine Learning Model File   |   < Go to file >

  •   Mode choosen: Logistic Regression
  •   Size: 1.2KB
  •   Accuracy: 97.94%

●   23 oct 2025   |   New Machine Learning Model File   |   < Go to file >

  •   Model choosen: Random Forest Classifier
  •   Size: 756.3MB
  •   Accuracy: 97.72%

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages