Code Monkey home page Code Monkey logo

make_distribution_python_client's Introduction

Python client for the MakeDistribution API (docs).

Offers a thin wrapper around the API (JSONClient) as well as the Distribution class which lets you interact with MakeDistribution.com distributions as if they were ordinary SciPy distribution objects.

At the moment, Distribution supports commonly used functionality which should be sufficient for the great majority of use cases. Eventually, the goal is to provide a full drop-in replacement for SciPy's distributions (specifically, rv_continuous_frozen).

Installation

pip install make_distribution  # or `poetry add make_distribution`

Usage

import os

import make_distribution.client

TOKEN = os.environ["MAKEDISTRIBUTION_API_TOKEN"]

json_client = make_distribution.client.JSONClient(token=TOKEN)

client = make_distribution.client.SciPyClient(json_client)

data = {
    "family": {"requested": "cinterp5_01"},
    "arguments": {
        "quantiles": [
            {
                "p": 0.1,
                "x": 0,
            },
            {
                "p": 0.5,
                "x": 1,
            },
            {
                "p": 0.9,
                "x": 4,
            },
        ]
    },
}

dist = client.post("1d/dists/", json=data)

# Print basic information about the distribution
print(dist)

# Query additional endpoints with a SciPy-like interface
# and print the results
x = [1, 2, 3]
print(f"cdf({x}) = {dist.cdf(x)}")
print(f"pdf({x}) = {dist.pdf(x)}")

p = [0.1, 0.2, 0.3]
print(f"ppf({p}) = {dist.ppf(p)}")

size = 5
print(f"rvs(size={size}) = {dist.rvs(size)}")

make_distribution_python_client's People

Contributors

tadamcz avatar

Stargazers

Nuño Sempere avatar  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.