ezmodel


Nameezmodel JSON
Version 0.2.1 PyPI version JSON
download
home_page
SummaryMachine Learning, Model, Surrogate, Metamodels, Response Surface
upload_time2023-11-25 22:13:17
maintainer
docs_urlNone
authorJulian Blank
requires_python>=3.6
licenseApache License 2.0
keywords model
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ezmodel - A Common Interface for Models and Model Selection
====================================================================

For more information about our toolbox, users are encouraged to read our documentation.
https://anyoptimization.com/projects/ezmodel/


|python| |license|


.. |python| image:: https://img.shields.io/badge/python-3.9-blue.svg
   :alt: python 3.6

.. |license| image:: https://img.shields.io/badge/license-apache-orange.svg
   :alt: license apache
   :target: https://www.apache.org/licenses/LICENSE-2.0



Installation
====================================================================

The official release is always available at PyPi:

.. code:: bash

    pip install -U ezmodel



Usage
==================================



Benchmarking
==================================


.. code:: python

    
    import numpy as np

    import pandas as pd
    pd.set_option('display.expand_frame_repr', False)
    pd.set_option('max_colwidth', 1000)

    from ezmodel.core.benchmark import Benchmark
    from ezmodel.core.factory import models_from_clazzes
    from ezmodel.models.kriging import Kriging
    from ezmodel.models.rbf import RBF
    from ezmodel.util.partitioning.crossvalidation import CrossvalidationPartitioning

    X = np.random.random((100, 3)) * 2 * np.pi
    y = np.sin(X).sum(axis=1)

    models = models_from_clazzes(RBF, Kriging)

    # set up the benchmark and add the models to be used
    benchmark = Benchmark(models, n_threads=4, verbose=True, raise_exception=True)

    # create partitions to validate the performance of each model
    partitions = CrossvalidationPartitioning(k_folds=5, seed=1).do(X)

    # runs the experiment with the specified partitioning
    benchmark.do(X, y, partitions=partitions)

    # print out the benchmark results
    print(benchmark.statistics("mae"))



::

                                                                      mae
                                                                     mean       std       min        max    median
    label
    Kriging[regr=constant,corr=gauss,thetaU=100,ARD=False]       0.017159  0.007472  0.009658   0.025359  0.014855
    Kriging[regr=constant,corr=gauss,thetaU=20,ARD=False]        0.017159  0.007472  0.009658   0.025359  0.014855
    Kriging[regr=linear,corr=gauss,thetaU=100,ARD=False]         0.018064  0.008069  0.010350   0.027456  0.014246
    Kriging[regr=linear,corr=gauss,thetaU=20,ARD=False]          0.018064  0.008069  0.010350   0.027456  0.014246
    Kriging[regr=constant,corr=gauss,thetaU=100,ARD=True]        0.021755  0.007409  0.011955   0.028896  0.025163
    Kriging[regr=constant,corr=gauss,thetaU=20,ARD=True]         0.021755  0.007409  0.011955   0.028896  0.025163
    Kriging[regr=linear,corr=gauss,thetaU=20,ARD=True]           0.025018  0.011348  0.011576   0.040585  0.022124
    Kriging[regr=linear,corr=gauss,thetaU=100,ARD=True]          0.025018  0.011348  0.011576   0.040585  0.022124
    Kriging[regr=constant,corr=exp,thetaU=100,ARD=False]         0.034493  0.009328  0.025092   0.045610  0.030661
    Kriging[regr=constant,corr=exp,thetaU=20,ARD=False]          0.034493  0.009328  0.025092   0.045610  0.030661
    Kriging[regr=linear,corr=exp,thetaU=100,ARD=False]           0.035734  0.009922  0.025611   0.047926  0.031473
    Kriging[regr=linear,corr=exp,thetaU=20,ARD=False]            0.035734  0.009922  0.025611   0.047926  0.031473
    Kriging[regr=constant,corr=exp,thetaU=100,ARD=True]          0.051527  0.010941  0.037944   0.065866  0.047440
    Kriging[regr=constant,corr=exp,thetaU=20,ARD=True]           0.051527  0.010941  0.037944   0.065866  0.047440
    Kriging[regr=linear,corr=exp,thetaU=100,ARD=True]            0.065867  0.025312  0.039058   0.104449  0.059957
    Kriging[regr=linear,corr=exp,thetaU=20,ARD=True]             0.065867  0.025312  0.039058   0.104449  0.059957
    RBF[kernel=cubic,tail=quadratic,normalized=True]             0.121947  0.033552  0.077895   0.167120  0.127345
    RBF[kernel=cubic,tail=constant,normalized=True]              0.125348  0.037982  0.072579   0.169413  0.140753
    RBF[kernel=cubic,tail=linear,normalized=True]                0.125474  0.038609  0.071268   0.169843  0.137987
    RBF[kernel=cubic,tail=linear+quadratic,normalized=True]      0.126070  0.039773  0.071279   0.171862  0.135489




RBF
----------------------------------


.. code:: python

    
    import matplotlib.pyplot as plt
    import numpy as np

    from ezmodel.models.rbf import RBF
    from ezmodel.util.sample_from_func import sine_function

    rbf = RBF(kernel="gaussian")

    # create some data to test this model on
    X, y, _X, _y = sine_function(20, 200)

    # let the model fit the data
    rbf.fit(X, y)

    # predict the data using the model
    y_hat = rbf.predict(_X)

    # predict the data using the model
    _X = _X[np.argsort(_X[:, 0])]
    y_hat = rbf.predict(_X)

    plt.scatter(X, y, label="Data")
    plt.plot(_X, y_hat, color="black", label="RBF")
    plt.legend()
    plt.show()



Kriging
----------------------------------


.. code:: python

    
    import matplotlib.pyplot as plt
    import numpy as np

    from ezmodel.models.kriging import Kriging
    from ezmodel.util.sample_from_func import square_function

    model = Kriging(regr="linear",
                    corr="gauss",
                    ARD=False)

    # create some data to test this model on
    X, y, _X, _y = square_function(100, 20)

    # let the model fit the data
    model.fit(X, y)

    # predict the data using the model
    y_hat = model.predict(_X)

    # predict the data using the model
    _X = _X[np.argsort(_X[:, 0])]
    y_hat = model.predict(_X)

    plt.scatter(X, y, label="Data")
    plt.plot(_X, y_hat, color="black", label="RBF")
    plt.legend()
    plt.show()




Contact
=======


Feel free to contact us if you have any question:

::

    Julian Blank (blankjul [at] msu.edu)
    Michigan State University
    Computational Optimization and Innovation Laboratory (COIN)
    East Lansing, MI 48824, USA

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "ezmodel",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "model",
    "author": "Julian Blank",
    "author_email": "blankjul@msu.edu",
    "download_url": "https://files.pythonhosted.org/packages/4c/d1/538d104e4377e1a3583ae9fc6a30e26f2b23b63755a9b14f2893d2be2278/ezmodel-0.2.1.tar.gz",
    "platform": "any",
    "description": "ezmodel - A Common Interface for Models and Model Selection\n====================================================================\n\nFor more information about our toolbox, users are encouraged to read our documentation.\nhttps://anyoptimization.com/projects/ezmodel/\n\n\n|python| |license|\n\n\n.. |python| image:: https://img.shields.io/badge/python-3.9-blue.svg\n   :alt: python 3.6\n\n.. |license| image:: https://img.shields.io/badge/license-apache-orange.svg\n   :alt: license apache\n   :target: https://www.apache.org/licenses/LICENSE-2.0\n\n\n\nInstallation\n====================================================================\n\nThe official release is always available at PyPi:\n\n.. code:: bash\n\n    pip install -U ezmodel\n\n\n\nUsage\n==================================\n\n\n\nBenchmarking\n==================================\n\n\n.. code:: python\n\n    \n    import numpy as np\n\n    import pandas as pd\n    pd.set_option('display.expand_frame_repr', False)\n    pd.set_option('max_colwidth', 1000)\n\n    from ezmodel.core.benchmark import Benchmark\n    from ezmodel.core.factory import models_from_clazzes\n    from ezmodel.models.kriging import Kriging\n    from ezmodel.models.rbf import RBF\n    from ezmodel.util.partitioning.crossvalidation import CrossvalidationPartitioning\n\n    X = np.random.random((100, 3)) * 2 * np.pi\n    y = np.sin(X).sum(axis=1)\n\n    models = models_from_clazzes(RBF, Kriging)\n\n    # set up the benchmark and add the models to be used\n    benchmark = Benchmark(models, n_threads=4, verbose=True, raise_exception=True)\n\n    # create partitions to validate the performance of each model\n    partitions = CrossvalidationPartitioning(k_folds=5, seed=1).do(X)\n\n    # runs the experiment with the specified partitioning\n    benchmark.do(X, y, partitions=partitions)\n\n    # print out the benchmark results\n    print(benchmark.statistics(\"mae\"))\n\n\n\n::\n\n                                                                      mae\n                                                                     mean       std       min        max    median\n    label\n    Kriging[regr=constant,corr=gauss,thetaU=100,ARD=False]       0.017159  0.007472  0.009658   0.025359  0.014855\n    Kriging[regr=constant,corr=gauss,thetaU=20,ARD=False]        0.017159  0.007472  0.009658   0.025359  0.014855\n    Kriging[regr=linear,corr=gauss,thetaU=100,ARD=False]         0.018064  0.008069  0.010350   0.027456  0.014246\n    Kriging[regr=linear,corr=gauss,thetaU=20,ARD=False]          0.018064  0.008069  0.010350   0.027456  0.014246\n    Kriging[regr=constant,corr=gauss,thetaU=100,ARD=True]        0.021755  0.007409  0.011955   0.028896  0.025163\n    Kriging[regr=constant,corr=gauss,thetaU=20,ARD=True]         0.021755  0.007409  0.011955   0.028896  0.025163\n    Kriging[regr=linear,corr=gauss,thetaU=20,ARD=True]           0.025018  0.011348  0.011576   0.040585  0.022124\n    Kriging[regr=linear,corr=gauss,thetaU=100,ARD=True]          0.025018  0.011348  0.011576   0.040585  0.022124\n    Kriging[regr=constant,corr=exp,thetaU=100,ARD=False]         0.034493  0.009328  0.025092   0.045610  0.030661\n    Kriging[regr=constant,corr=exp,thetaU=20,ARD=False]          0.034493  0.009328  0.025092   0.045610  0.030661\n    Kriging[regr=linear,corr=exp,thetaU=100,ARD=False]           0.035734  0.009922  0.025611   0.047926  0.031473\n    Kriging[regr=linear,corr=exp,thetaU=20,ARD=False]            0.035734  0.009922  0.025611   0.047926  0.031473\n    Kriging[regr=constant,corr=exp,thetaU=100,ARD=True]          0.051527  0.010941  0.037944   0.065866  0.047440\n    Kriging[regr=constant,corr=exp,thetaU=20,ARD=True]           0.051527  0.010941  0.037944   0.065866  0.047440\n    Kriging[regr=linear,corr=exp,thetaU=100,ARD=True]            0.065867  0.025312  0.039058   0.104449  0.059957\n    Kriging[regr=linear,corr=exp,thetaU=20,ARD=True]             0.065867  0.025312  0.039058   0.104449  0.059957\n    RBF[kernel=cubic,tail=quadratic,normalized=True]             0.121947  0.033552  0.077895   0.167120  0.127345\n    RBF[kernel=cubic,tail=constant,normalized=True]              0.125348  0.037982  0.072579   0.169413  0.140753\n    RBF[kernel=cubic,tail=linear,normalized=True]                0.125474  0.038609  0.071268   0.169843  0.137987\n    RBF[kernel=cubic,tail=linear+quadratic,normalized=True]      0.126070  0.039773  0.071279   0.171862  0.135489\n\n\n\n\nRBF\n----------------------------------\n\n\n.. code:: python\n\n    \n    import matplotlib.pyplot as plt\n    import numpy as np\n\n    from ezmodel.models.rbf import RBF\n    from ezmodel.util.sample_from_func import sine_function\n\n    rbf = RBF(kernel=\"gaussian\")\n\n    # create some data to test this model on\n    X, y, _X, _y = sine_function(20, 200)\n\n    # let the model fit the data\n    rbf.fit(X, y)\n\n    # predict the data using the model\n    y_hat = rbf.predict(_X)\n\n    # predict the data using the model\n    _X = _X[np.argsort(_X[:, 0])]\n    y_hat = rbf.predict(_X)\n\n    plt.scatter(X, y, label=\"Data\")\n    plt.plot(_X, y_hat, color=\"black\", label=\"RBF\")\n    plt.legend()\n    plt.show()\n\n\n\nKriging\n----------------------------------\n\n\n.. code:: python\n\n    \n    import matplotlib.pyplot as plt\n    import numpy as np\n\n    from ezmodel.models.kriging import Kriging\n    from ezmodel.util.sample_from_func import square_function\n\n    model = Kriging(regr=\"linear\",\n                    corr=\"gauss\",\n                    ARD=False)\n\n    # create some data to test this model on\n    X, y, _X, _y = square_function(100, 20)\n\n    # let the model fit the data\n    model.fit(X, y)\n\n    # predict the data using the model\n    y_hat = model.predict(_X)\n\n    # predict the data using the model\n    _X = _X[np.argsort(_X[:, 0])]\n    y_hat = model.predict(_X)\n\n    plt.scatter(X, y, label=\"Data\")\n    plt.plot(_X, y_hat, color=\"black\", label=\"RBF\")\n    plt.legend()\n    plt.show()\n\n\n\n\nContact\n=======\n\n\nFeel free to contact us if you have any question:\n\n::\n\n    Julian Blank (blankjul [at] msu.edu)\n    Michigan State University\n    Computational Optimization and Innovation Laboratory (COIN)\n    East Lansing, MI 48824, USA\n",
    "bugtrack_url": null,
    "license": "Apache License 2.0",
    "summary": "Machine Learning, Model, Surrogate, Metamodels, Response Surface",
    "version": "0.2.1",
    "project_urls": null,
    "split_keywords": [
        "model"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4cd1538d104e4377e1a3583ae9fc6a30e26f2b23b63755a9b14f2893d2be2278",
                "md5": "83965d633ea60daa95e1ca61cd81d0f4",
                "sha256": "e72d44b87cc13b7400240a9b56ad6ee4b447b0498b6a02829f77cf7afeee5a0d"
            },
            "downloads": -1,
            "filename": "ezmodel-0.2.1.tar.gz",
            "has_sig": false,
            "md5_digest": "83965d633ea60daa95e1ca61cd81d0f4",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 27802,
            "upload_time": "2023-11-25T22:13:17",
            "upload_time_iso_8601": "2023-11-25T22:13:17.952489Z",
            "url": "https://files.pythonhosted.org/packages/4c/d1/538d104e4377e1a3583ae9fc6a30e26f2b23b63755a9b14f2893d2be2278/ezmodel-0.2.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-11-25 22:13:17",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "ezmodel"
}
        
Elapsed time: 0.21424s