Skip to content

Latest commit

 

History

41 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cat database in Flask with machine learning prediction

Python Flask SQLAlchemy Scikit-Learn

A web application project developed at Lodz University of Technology. It combines a Flask backend with database management, REST API endpoints, and Machine Learning integration.

The app serves as a registry for cat data and features a k-Nearest Neighbors (k-NN) model to predict breeds based on physical attributes stored in the database.

Features

  • CRUD: REST API allows user to manage database records (Create, Read, Delete)
  • Machine Learning: AI Model provides cat breed prediction using a k-NN classifier trained on the current dataset.
  • Validation: Robust user input validation and HTTP error handling. It was crucial for us to eliminate vulnerabilities similar to SQL Injection.
  • SQLAlchemy: Is used for secure SQLite database interactions and object-relational mapping.
  • JSON: Returned by API Endpoints for external integration.

Tech

Backend was made in Python 3.8+, with the addition of Flask web interface.

Database is created through SQLite extension, provided by Python.

SQLAlchemy ensures proper ORM.

AI was created using Scikit-learn model with the usage of StandardScaler and K-nn classifier.

Testing was made with Unittest and Requests - both included in Python package.

Frontend is using HTML5 with Jinja2 templates and a simple CSS file for visuals.

Installation

  1. Clone the repository

    git clone https://github.com/velosysop/webcatt-app.git
    cd webcatt-app
  2. Install additional libraries

    pip install flask flask-sqlalchemy scikit-learn requests
  3. Run it!

    python main.py

    ...or just double-click ;)
    The server will start at http://127.0.0.1:5000.

API

The following REST Endpoints are exposed:

Method Endpoint Description Example parameters
GET /api/data Retrieve all records -
POST /api/data Add a new record {"weight": 4.5, "tail_length": 30.0, "breed": 1}
DELETE /api/data/<id> Delete a record by ID -
GET /api/predictions Predict breed (AI) ?weight=5.0&tail_length=25.5

Tests

Automated tests were created and saved to file test.py. They verify API and error handling.

In order to run tests, you must run the server in one terminal, and then launch test.py in other terminal.

About

Python+Flask web application with elements of SQLite and AI Machine Learning

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages