Giter VIP home page Giter VIP logo

policy-options-api's Introduction

policy-options-api

Welcome to the Policy Options Suggestion Predictor!

This repository contains a FastAPI backend application that can predict whether a given piece of text contains suggestions for policy options. It uses a machine learning model trained on a dataset of policy documents to make these predictions.

To use this app, you will need to have docker and docker-compose installed on your machine.

Once everything is set up, you can start the app by running docker-compose up. This will start the FastAPI server, which you can access at the default address (http://127.0.0.1:8000).

The app has a single endpoint, /api/policy-options/predict, which you can send a POST request to with a JSON payload containing the text you want to predict on. The endpoint will return a JSON response with two keys:

  • text: the input text that was sent in the request
  • policy options: a float value indicating the model's confidence that the input text contains policy options suggestions. The higher the value, the higher the confidence.

An example of how you might use this endpoint is shown below:

import requests


def predict(s: str) -> float:
    """Make a prediction on whether the input text contains policy options suggestions.

    Parameters
    ----------
    s : str
        The input text to make a prediction on.

    Returns
    -------
    float
        A float value indicating the model's confidence that the input text contains policy options suggestions. 
        The higher the value, the higher the confidence. If an error occurs, returns 0.0."""

    response = requests.post(
        "http://127.0.0.1:8000/api/policy-options/predict?token=policy-options-2022",
        json={"text": s}
    if response.status == 200:
        return response.json()["policy option suggestion"]
    else:
        return 0.0


if __name__ == "__main__":
    sentences = [
        "China and Russia can either tailor messaging in combined...", 
        "Rather than wait for a miracle, policymakers should create a strategy..."
    ]
    for sent in sentences:
        score = predict(sent)
        ...

policy-options-api's People

Contributors

hp0404 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.