ddop2


Nameddop2 JSON
Version 0.0.11 PyPI version JSON
download
home_pagehttps://github.com/opimwue/ddop2
SummaryRestructuring of ddop
upload_time2024-11-19 20:55:17
maintainerNone
docs_urlNone
authorkaiguender
requires_python>=3.7
licenseApache Software License 2.0
keywords nbdev jupyter notebook python
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Welcome to ddop


<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->

`ddop` is a Python library for data-driven operations management. The
goal of `ddop` is to provide well-established data-driven operations
management tools within a programming environment that is accessible and
easy to use even for non-experts. At the current state `ddop` contains
well known data-driven newsvendor models, a set of performance metrics
that can be used for model evaluation and selection, as well as datasets
that are useful to quickly illustrate the behavior of the various
algorithms implemented in `ddop` or as benchmark for testing new models.
Through its consistent and easy-to-use interface one can run and compare
provided models with only a few lines of code.

## Install

`ddop` is available via PyPI using:

``` sh
pip install ddop2
```

The installation of this package requires the following dependencies:

- numpy==1.18.2
- scipy==1.4.1
- pandas==1.1.4
- statsmodels==0.11.1
- scikit-learn==0.23.0
- tensorflow==2.4.1
- pulp==2.0
- mpmath

**Note:** The package is actively developed, and conflicts with other
packages may occur during installation. To avoid any installation
conflicts, we recommend installing the package in an empty environment
with the above-mentioned dependencies.

## Quickstart

`ddop` provides a varity of newsvendor models. The following example
shows how to use one of these models for decision making. It assumes a
very basic knowledge of data-driven operations management practices.

As first step we initialize the model we want to use. In this example
`RandomForestWeightedNewsvendor`.

``` python
from ddop2.newsvendor import RandomForestWeightedNewsvendor
rf_nv = RandomForestWeightedNewsvendor(cu=2, co=1)
```

    2023-08-09 22:10:47.225307: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
    To enable the following instructions: AVX2 FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
    2023-08-09 22:10:48.239997: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT

A model can take a set of parameters, each describing the model or the
optimization problem it tries to solve. Here we set the underage costs
cu to 2 and the overage costs co to 1.

As next step we load the Yaz Dataset and split it into train and test
set.

``` python
from ddop2.datasets import load_yaz
from sklearn.model_selection import train_test_split
X, y = load_yaz(one_hot_encoding=True, return_X_y=True)
X_train, X_test, y_train, y_test = train_test_split(X, y, shuffle=False, random_state=0)
```

After the model is initialized, the `fit` method can be used to learn a
decision model from the training data `X_train`, `y_train`.

``` python
rf_nv.fit(X_train, y_train)
```

<style>#sk-container-id-1 {color: black;background-color: white;}#sk-container-id-1 pre{padding: 0;}#sk-container-id-1 div.sk-toggleable {background-color: white;}#sk-container-id-1 label.sk-toggleable__label {cursor: pointer;display: block;width: 100%;margin-bottom: 0;padding: 0.3em;box-sizing: border-box;text-align: center;}#sk-container-id-1 label.sk-toggleable__label-arrow:before {content: "▸";float: left;margin-right: 0.25em;color: #696969;}#sk-container-id-1 label.sk-toggleable__label-arrow:hover:before {color: black;}#sk-container-id-1 div.sk-estimator:hover label.sk-toggleable__label-arrow:before {color: black;}#sk-container-id-1 div.sk-toggleable__content {max-height: 0;max-width: 0;overflow: hidden;text-align: left;background-color: #f0f8ff;}#sk-container-id-1 div.sk-toggleable__content pre {margin: 0.2em;color: black;border-radius: 0.25em;background-color: #f0f8ff;}#sk-container-id-1 input.sk-toggleable__control:checked~div.sk-toggleable__content {max-height: 200px;max-width: 100%;overflow: auto;}#sk-container-id-1 input.sk-toggleable__control:checked~label.sk-toggleable__label-arrow:before {content: "▾";}#sk-container-id-1 div.sk-estimator input.sk-toggleable__control:checked~label.sk-toggleable__label {background-color: #d4ebff;}#sk-container-id-1 div.sk-label input.sk-toggleable__control:checked~label.sk-toggleable__label {background-color: #d4ebff;}#sk-container-id-1 input.sk-hidden--visually {border: 0;clip: rect(1px 1px 1px 1px);clip: rect(1px, 1px, 1px, 1px);height: 1px;margin: -1px;overflow: hidden;padding: 0;position: absolute;width: 1px;}#sk-container-id-1 div.sk-estimator {font-family: monospace;background-color: #f0f8ff;border: 1px dotted black;border-radius: 0.25em;box-sizing: border-box;margin-bottom: 0.5em;}#sk-container-id-1 div.sk-estimator:hover {background-color: #d4ebff;}#sk-container-id-1 div.sk-parallel-item::after {content: "";width: 100%;border-bottom: 1px solid gray;flex-grow: 1;}#sk-container-id-1 div.sk-label:hover label.sk-toggleable__label {background-color: #d4ebff;}#sk-container-id-1 div.sk-serial::before {content: "";position: absolute;border-left: 1px solid gray;box-sizing: border-box;top: 0;bottom: 0;left: 50%;z-index: 0;}#sk-container-id-1 div.sk-serial {display: flex;flex-direction: column;align-items: center;background-color: white;padding-right: 0.2em;padding-left: 0.2em;position: relative;}#sk-container-id-1 div.sk-item {position: relative;z-index: 1;}#sk-container-id-1 div.sk-parallel {display: flex;align-items: stretch;justify-content: center;background-color: white;position: relative;}#sk-container-id-1 div.sk-item::before, #sk-container-id-1 div.sk-parallel-item::before {content: "";position: absolute;border-left: 1px solid gray;box-sizing: border-box;top: 0;bottom: 0;left: 50%;z-index: -1;}#sk-container-id-1 div.sk-parallel-item {display: flex;flex-direction: column;z-index: 1;position: relative;background-color: white;}#sk-container-id-1 div.sk-parallel-item:first-child::after {align-self: flex-end;width: 50%;}#sk-container-id-1 div.sk-parallel-item:last-child::after {align-self: flex-start;width: 50%;}#sk-container-id-1 div.sk-parallel-item:only-child::after {width: 0;}#sk-container-id-1 div.sk-dashed-wrapped {border: 1px dashed gray;margin: 0 0.4em 0.5em 0.4em;box-sizing: border-box;padding-bottom: 0.4em;background-color: white;}#sk-container-id-1 div.sk-label label {font-family: monospace;font-weight: bold;display: inline-block;line-height: 1.2em;}#sk-container-id-1 div.sk-label-container {text-align: center;}#sk-container-id-1 div.sk-container {/* jupyter's `normalize.less` sets `[hidden] { display: none; }` but bootstrap.min.css set `[hidden] { display: none !important; }` so we also need the `!important` here to be able to override the default hidden behavior on the sphinx rendered scikit-learn.org. See: https://github.com/scikit-learn/scikit-learn/issues/21755 */display: inline-block !important;position: relative;}#sk-container-id-1 div.sk-text-repr-fallback {display: none;}</style><div id="sk-container-id-1" class="sk-top-container"><div class="sk-text-repr-fallback"><pre>RandomForestWeightedNewsvendor(co=1, cu=2)</pre><b>In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook. <br />On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.</b></div><div class="sk-container" hidden><div class="sk-item"><div class="sk-estimator sk-toggleable"><input class="sk-toggleable__control sk-hidden--visually" id="sk-estimator-id-1" type="checkbox" checked><label for="sk-estimator-id-1" class="sk-toggleable__label sk-toggleable__label-arrow">RandomForestWeightedNewsvendor</label><div class="sk-toggleable__content"><pre>RandomForestWeightedNewsvendor(co=1, cu=2)</pre></div></div></div></div></div>

We can then use the predict method to make a decision for new data
samples.

``` python
rf_nv.predict(X_test)
```

    array([[ 5,  4, 14, ..., 23, 35, 22],
           [ 6,  6, 11, ..., 26, 37, 23],
           [ 8,  8, 16, ..., 35, 55, 40],
           ...,
           [ 5,  6, 12, ..., 23, 41, 25],
           [ 6,  6, 13, ..., 24, 41, 32],
           [ 8,  9, 15, ..., 34, 57, 42]])

To get a representation of the model’s decision quality we can use the
`score` function, which takes as input `X_test` and `y_test`. The
`score` function makes a decision for each sample in `X_test` and
calculates the negated average costs with respect to the true values
`y_test` and the overage and underage costs.

``` python
rf_nv.score(X_test, y_test)
```

    -6.859375000000001

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/opimwue/ddop2",
    "name": "ddop2",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "nbdev jupyter notebook python",
    "author": "kaiguender",
    "author_email": "kai.guender@yahoo.de",
    "download_url": "https://files.pythonhosted.org/packages/40/1c/ac9adaaf247ff1876a378b9843cd5b4f48c67f7c4ce61d4d0427f3e51ee3/ddop2-0.0.11.tar.gz",
    "platform": null,
    "description": "# Welcome to ddop\n\n\n<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->\n\n`ddop` is a Python library for data-driven operations management. The\ngoal of `ddop` is to provide well-established data-driven operations\nmanagement tools within a programming environment that is accessible and\neasy to use even for non-experts. At the current state `ddop` contains\nwell known data-driven newsvendor models, a set of performance metrics\nthat can be used for model evaluation and selection, as well as datasets\nthat are useful to quickly illustrate the behavior of the various\nalgorithms implemented in `ddop` or as benchmark for testing new models.\nThrough its consistent and easy-to-use interface one can run and compare\nprovided models with only a few lines of code.\n\n## Install\n\n`ddop` is available via PyPI using:\n\n``` sh\npip install ddop2\n```\n\nThe installation of this package requires the following dependencies:\n\n- numpy==1.18.2\n- scipy==1.4.1\n- pandas==1.1.4\n- statsmodels==0.11.1\n- scikit-learn==0.23.0\n- tensorflow==2.4.1\n- pulp==2.0\n- mpmath\n\n**Note:** The package is actively developed, and conflicts with other\npackages may occur during installation. To avoid any installation\nconflicts, we recommend installing the package in an empty environment\nwith the above-mentioned dependencies.\n\n## Quickstart\n\n`ddop` provides a varity of newsvendor models. The following example\nshows how to use one of these models for decision making. It assumes a\nvery basic knowledge of data-driven operations management practices.\n\nAs first step we initialize the model we want to use. In this example\n`RandomForestWeightedNewsvendor`.\n\n``` python\nfrom ddop2.newsvendor import RandomForestWeightedNewsvendor\nrf_nv = RandomForestWeightedNewsvendor(cu=2, co=1)\n```\n\n    2023-08-09 22:10:47.225307: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.\n    To enable the following instructions: AVX2 FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.\n    2023-08-09 22:10:48.239997: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT\n\nA model can take a set of parameters, each describing the model or the\noptimization problem it tries to solve. Here we set the underage costs\ncu to 2 and the overage costs co to 1.\n\nAs next step we load the Yaz Dataset and split it into train and test\nset.\n\n``` python\nfrom ddop2.datasets import load_yaz\nfrom sklearn.model_selection import train_test_split\nX, y = load_yaz(one_hot_encoding=True, return_X_y=True)\nX_train, X_test, y_train, y_test = train_test_split(X, y, shuffle=False, random_state=0)\n```\n\nAfter the model is initialized, the `fit` method can be used to learn a\ndecision model from the training data `X_train`, `y_train`.\n\n``` python\nrf_nv.fit(X_train, y_train)\n```\n\n<style>#sk-container-id-1 {color: black;background-color: white;}#sk-container-id-1 pre{padding: 0;}#sk-container-id-1 div.sk-toggleable {background-color: white;}#sk-container-id-1 label.sk-toggleable__label {cursor: pointer;display: block;width: 100%;margin-bottom: 0;padding: 0.3em;box-sizing: border-box;text-align: center;}#sk-container-id-1 label.sk-toggleable__label-arrow:before {content: \"\u25b8\";float: left;margin-right: 0.25em;color: #696969;}#sk-container-id-1 label.sk-toggleable__label-arrow:hover:before {color: black;}#sk-container-id-1 div.sk-estimator:hover label.sk-toggleable__label-arrow:before {color: black;}#sk-container-id-1 div.sk-toggleable__content {max-height: 0;max-width: 0;overflow: hidden;text-align: left;background-color: #f0f8ff;}#sk-container-id-1 div.sk-toggleable__content pre {margin: 0.2em;color: black;border-radius: 0.25em;background-color: #f0f8ff;}#sk-container-id-1 input.sk-toggleable__control:checked~div.sk-toggleable__content {max-height: 200px;max-width: 100%;overflow: auto;}#sk-container-id-1 input.sk-toggleable__control:checked~label.sk-toggleable__label-arrow:before {content: \"\u25be\";}#sk-container-id-1 div.sk-estimator input.sk-toggleable__control:checked~label.sk-toggleable__label {background-color: #d4ebff;}#sk-container-id-1 div.sk-label input.sk-toggleable__control:checked~label.sk-toggleable__label {background-color: #d4ebff;}#sk-container-id-1 input.sk-hidden--visually {border: 0;clip: rect(1px 1px 1px 1px);clip: rect(1px, 1px, 1px, 1px);height: 1px;margin: -1px;overflow: hidden;padding: 0;position: absolute;width: 1px;}#sk-container-id-1 div.sk-estimator {font-family: monospace;background-color: #f0f8ff;border: 1px dotted black;border-radius: 0.25em;box-sizing: border-box;margin-bottom: 0.5em;}#sk-container-id-1 div.sk-estimator:hover {background-color: #d4ebff;}#sk-container-id-1 div.sk-parallel-item::after {content: \"\";width: 100%;border-bottom: 1px solid gray;flex-grow: 1;}#sk-container-id-1 div.sk-label:hover label.sk-toggleable__label {background-color: #d4ebff;}#sk-container-id-1 div.sk-serial::before {content: \"\";position: absolute;border-left: 1px solid gray;box-sizing: border-box;top: 0;bottom: 0;left: 50%;z-index: 0;}#sk-container-id-1 div.sk-serial {display: flex;flex-direction: column;align-items: center;background-color: white;padding-right: 0.2em;padding-left: 0.2em;position: relative;}#sk-container-id-1 div.sk-item {position: relative;z-index: 1;}#sk-container-id-1 div.sk-parallel {display: flex;align-items: stretch;justify-content: center;background-color: white;position: relative;}#sk-container-id-1 div.sk-item::before, #sk-container-id-1 div.sk-parallel-item::before {content: \"\";position: absolute;border-left: 1px solid gray;box-sizing: border-box;top: 0;bottom: 0;left: 50%;z-index: -1;}#sk-container-id-1 div.sk-parallel-item {display: flex;flex-direction: column;z-index: 1;position: relative;background-color: white;}#sk-container-id-1 div.sk-parallel-item:first-child::after {align-self: flex-end;width: 50%;}#sk-container-id-1 div.sk-parallel-item:last-child::after {align-self: flex-start;width: 50%;}#sk-container-id-1 div.sk-parallel-item:only-child::after {width: 0;}#sk-container-id-1 div.sk-dashed-wrapped {border: 1px dashed gray;margin: 0 0.4em 0.5em 0.4em;box-sizing: border-box;padding-bottom: 0.4em;background-color: white;}#sk-container-id-1 div.sk-label label {font-family: monospace;font-weight: bold;display: inline-block;line-height: 1.2em;}#sk-container-id-1 div.sk-label-container {text-align: center;}#sk-container-id-1 div.sk-container {/* jupyter's `normalize.less` sets `[hidden] { display: none; }` but bootstrap.min.css set `[hidden] { display: none !important; }` so we also need the `!important` here to be able to override the default hidden behavior on the sphinx rendered scikit-learn.org. See: https://github.com/scikit-learn/scikit-learn/issues/21755 */display: inline-block !important;position: relative;}#sk-container-id-1 div.sk-text-repr-fallback {display: none;}</style><div id=\"sk-container-id-1\" class=\"sk-top-container\"><div class=\"sk-text-repr-fallback\"><pre>RandomForestWeightedNewsvendor(co=1, cu=2)</pre><b>In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook. <br />On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.</b></div><div class=\"sk-container\" hidden><div class=\"sk-item\"><div class=\"sk-estimator sk-toggleable\"><input class=\"sk-toggleable__control sk-hidden--visually\" id=\"sk-estimator-id-1\" type=\"checkbox\" checked><label for=\"sk-estimator-id-1\" class=\"sk-toggleable__label sk-toggleable__label-arrow\">RandomForestWeightedNewsvendor</label><div class=\"sk-toggleable__content\"><pre>RandomForestWeightedNewsvendor(co=1, cu=2)</pre></div></div></div></div></div>\n\nWe can then use the predict method to make a decision for new data\nsamples.\n\n``` python\nrf_nv.predict(X_test)\n```\n\n    array([[ 5,  4, 14, ..., 23, 35, 22],\n           [ 6,  6, 11, ..., 26, 37, 23],\n           [ 8,  8, 16, ..., 35, 55, 40],\n           ...,\n           [ 5,  6, 12, ..., 23, 41, 25],\n           [ 6,  6, 13, ..., 24, 41, 32],\n           [ 8,  9, 15, ..., 34, 57, 42]])\n\nTo get a representation of the model\u2019s decision quality we can use the\n`score` function, which takes as input `X_test` and `y_test`. The\n`score` function makes a decision for each sample in `X_test` and\ncalculates the negated average costs with respect to the true values\n`y_test` and the overage and underage costs.\n\n``` python\nrf_nv.score(X_test, y_test)\n```\n\n    -6.859375000000001\n",
    "bugtrack_url": null,
    "license": "Apache Software License 2.0",
    "summary": "Restructuring of ddop",
    "version": "0.0.11",
    "project_urls": {
        "Homepage": "https://github.com/opimwue/ddop2"
    },
    "split_keywords": [
        "nbdev",
        "jupyter",
        "notebook",
        "python"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2db9013e65de5b98eb2a37cb75b4eaa26dc392874c49cd86c2f7c5326d0c816f",
                "md5": "e22e997cbceaaa85fb3abfd4aa700464",
                "sha256": "be443a48394cbf0ffbfa9ea0522eae9bd1f5bc6440d39fdb1fedd26ca4e8f7a2"
            },
            "downloads": -1,
            "filename": "ddop2-0.0.11-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e22e997cbceaaa85fb3abfd4aa700464",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 4174609,
            "upload_time": "2024-11-19T20:55:15",
            "upload_time_iso_8601": "2024-11-19T20:55:15.720492Z",
            "url": "https://files.pythonhosted.org/packages/2d/b9/013e65de5b98eb2a37cb75b4eaa26dc392874c49cd86c2f7c5326d0c816f/ddop2-0.0.11-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "401cac9adaaf247ff1876a378b9843cd5b4f48c67f7c4ce61d4d0427f3e51ee3",
                "md5": "c194f57c138723b6900db2f5286d4fd9",
                "sha256": "904a471940353bfad87bcf73379537e603a021d83cd15925a9cd007b6d8b5e70"
            },
            "downloads": -1,
            "filename": "ddop2-0.0.11.tar.gz",
            "has_sig": false,
            "md5_digest": "c194f57c138723b6900db2f5286d4fd9",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 4155208,
            "upload_time": "2024-11-19T20:55:17",
            "upload_time_iso_8601": "2024-11-19T20:55:17.459161Z",
            "url": "https://files.pythonhosted.org/packages/40/1c/ac9adaaf247ff1876a378b9843cd5b4f48c67f7c4ce61d4d0427f3e51ee3/ddop2-0.0.11.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-19 20:55:17",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "opimwue",
    "github_project": "ddop2",
    "github_not_found": true,
    "lcname": "ddop2"
}
        
Elapsed time: 0.83969s