Giter Site home page Giter Site logo

my_app's Introduction

Recidivism Prediction API

This repository contains the code for a Flask-based API that predicts the likelihood of recidivism based on provided input data. The API provides endpoints to submit data for prediction and to retrieve prediction results.

Table of Contents

  • Installation
  • Configuration
  • Usage
  • Endpoints
  • Database Schema
  • Logging
  • License

Installation

To set up the project locally, follow these steps:

  1. Clone the repository:
git clone https://github.com/your-repo/recidivism-prediction-api.git
cd recidivism-prediction-api
  1. Create and activate a virtual environment:
python3 -m venv venv
source venv/bin/activate
  1. Install the required packages (DEV):
pip install -r requirements_dev.txt
  1. Ensure you have the necessary data files in the data directory:
  • columns.json
  • dtypes.pickle
  • pipeline.pickle

Configuration

The application relies on environment variables for configuration. The primary environment variable is DATABASE_URL, which specifies the database connection string. If not set, the application defaults to using a local SQLite database (sqlite:///predicts.db).

Usage

To start the Flask application, run the following command:

python app.py

The API will be available at http://0.0.0.0:5000

Endpoints

/will_recidivate/ [POST]

Predicts the likelihood of recidivism for the given input data.

  • Request Body: JSON
{
    "id": 1234,
    "name": "rui antonio",
    "sex": "Male",
    "dob": "1987-06-21",
    "race": "Caucasian",
    "juv_fel_count": 0,
    "juv_misd_count": 3,
    "juv_other_count": 0,
    "priors_count": 5,
    "c_case_number": "13022428MM10A",
    "c_charge_degree": "F",
    "c_charge_desc": "Driving Under The Influence",
    "c_offense_date": "2013-08-19",
    "c_arrest_date": "2013-09-07",
    "c_jail_in": "2013-09-20 06:32:00",
}
  • Response: JSON
{
  "id": 1234,
  "outcome": true
}

/recidivism_result/ [POST]

Updates the true outcome for a prediction and retrieves the stored prediction.

{
  "id": 1234,
  "outcome": true
}
  • Response: JSON
{
  "id": 1234,
  "outcome": true,
  "predicted_outcome": false
}

Database Schema

The application uses a SQLite database (or other databases via the DATABASE_URL environment variable) with the following schema:

Prediction

  • observation_id (Integer, unique)
  • observation (Text)
  • pred (Boolean)
  • pred_proba (Float)
  • true_class (Integer, nullable)

Logging

The application uses Python's built-in logging module to log information. Logs are configured to display messages at the INFO level and higher.

License

This project is licensed under the MIT License. See the LICENSE file for more details.

my_app's People

Contributors

ruifsp avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.