randomstatsmodels


Namerandomstatsmodels JSON
Version 1.1.2 PyPI version JSON
download
home_pageNone
SummaryTools for benchmarking, metrics, and models.
upload_time2025-08-29 18:37:57
maintainerNone
docs_urlNone
authorJacob Wright
requires_python>=3.9
licenseMIT License Copyright (c) 2025 Jacob Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords statistics metrics machine-learning forecasting evaluation error-metrics model-selection time-series analysis
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # randomstatsmodels
Check out medium story here: [Medium Story](https://medium.com/@jacoblouiswright/univarient-forecasting-models-2025-c483d04f04d8) <br></br>
Lightweight utilities for benchmarking, forecasting, and statistical modeling — with simple `Auto*` model wrappers that tune hyperparameters for you.

## Installation

```bash
pip install randomstatsmodels
```

Requires: Python 3.9+ and NumPy.

---

## Quick Start

```python
from randomstatsmodels import AutoNEO, AutoFourier, AutoKNN, AutoPolymath, AutoThetaAR
import numpy as np

# Toy data: sine wave + noise
rng = np.random.default_rng(42)
t = np.arange(200)
y = np.sin(2*np.pi*t/24) + 0.1*rng.normal(size=t.size)

h = 12  # forecast horizon

model = AutoNEO().fit(y)
yhat = model.predict(h)
print("Forecast:", yhat[:5])
```

---

## Models

Each `Auto*` class:
- accepts a **parameter grid** (or uses sensible defaults),
- fits/evaluates candidates using a chosen metric,
- exposes a unified API: `.fit(y[, X])` and `.predict(h)`.

### AutoNEO

```python
from randomstatsmodels import AutoNEO

neo = AutoNEO(
    param_grid={"n_components": [8, 16, 32]},
    metric="mae",
)
neo.fit(y)
print("Best params:", neo.best_params_)
print("Prediction:", neo.predict(h))
```

### AutoFourier

```python
from randomstatsmodels import AutoFourier

fourier = AutoFourier(
    param_grid={"season_length": [12, 24], "n_terms": [3, 5]},
    metric="smape",
)
fourier.fit(y)
print("Prediction:", fourier.predict(h))
```

### AutoKNN

```python
from randomstatsmodels import AutoKNN

knn = AutoKNN(
    param_grid={"k": [3, 5, 7], "window": [12, 24]},
    metric="rmse",
)
knn.fit(y)
print("Prediction:", knn.predict(h))
```

### AutoPolymath

```python
from randomstatsmodels import AutoPolymath

poly = AutoPolymath(
    param_grid={"degree": [2, 3], "ridge": [0.0, 0.1]},
    metric="mae",
)
poly.fit(y)
print("Prediction:", poly.predict(h))
```

### AutoThetaAR

```python
from randomstatsmodels import AutoThetaAR

theta = AutoThetaAR(
    param_grid={"theta": [0.5, 1.0, 2.0]},
    metric="mape",
)
theta.fit(y)
print("Prediction:", theta.predict(h))
```

### AutoHybridForecaster

```python
from randomstatsmodels import AutoHybridForecaster

hybrid = AutoHybridForecaster(
    candidate_fourier=(0, 3, 6),
    candidate_trend=(0, 1),
    candidate_ar=(0, 3, 5),
    candidate_hidden=(8, 16, 32),
)
hybrid.fit(y)
print("Best config:", hybrid.best_config)
print("Prediction:", hybrid.predict(h))
```

### AutoMELD

```python
from randomstatsmodels import AutoMELD

meld = AutoMELD(
    lags_grid=(8, 12),
    scales_grid=((1, 3, 7), (1, 2, 4, 8)),
    rff_features_grid=(64, 128),
)
meld.fit(y)
print("Best config:", meld.best_["config"])
print("Prediction:", meld.predict(h))
```

### AutoPALF

```python
from randomstatsmodels import AutoPALF

palf = AutoPALF(
    p_candidates=(4, 8, 12),
    penalties=("huber", "l2"),
)
palf.fit(y)
print("Validation score:", palf.best_["val_score"])
print("Prediction:", palf.predict(h))
```

---

## Metrics

Available out of the box:

```python
from randomstatsmodels.metrics import mae, mse, rmse, mape, smape
```

---

## License

MIT © 2025 Jacob Wright

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "randomstatsmodels",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "statistics, metrics, machine-learning, forecasting, evaluation, error-metrics, model-selection, time-series, analysis",
    "author": "Jacob Wright",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/e9/e9/b07e4a1126bb7e2f6daa293c077efb085a929f82c2b1029f7db749462bb3/randomstatsmodels-1.1.2.tar.gz",
    "platform": null,
    "description": "# randomstatsmodels\r\nCheck out medium story here: [Medium Story](https://medium.com/@jacoblouiswright/univarient-forecasting-models-2025-c483d04f04d8) <br></br>\r\nLightweight utilities for benchmarking, forecasting, and statistical modeling \u2014 with simple `Auto*` model wrappers that tune hyperparameters for you.\r\n\r\n## Installation\r\n\r\n```bash\r\npip install randomstatsmodels\r\n```\r\n\r\nRequires: Python 3.9+ and NumPy.\r\n\r\n---\r\n\r\n## Quick Start\r\n\r\n```python\r\nfrom randomstatsmodels import AutoNEO, AutoFourier, AutoKNN, AutoPolymath, AutoThetaAR\r\nimport numpy as np\r\n\r\n# Toy data: sine wave + noise\r\nrng = np.random.default_rng(42)\r\nt = np.arange(200)\r\ny = np.sin(2*np.pi*t/24) + 0.1*rng.normal(size=t.size)\r\n\r\nh = 12  # forecast horizon\r\n\r\nmodel = AutoNEO().fit(y)\r\nyhat = model.predict(h)\r\nprint(\"Forecast:\", yhat[:5])\r\n```\r\n\r\n---\r\n\r\n## Models\r\n\r\nEach `Auto*` class:\r\n- accepts a **parameter grid** (or uses sensible defaults),\r\n- fits/evaluates candidates using a chosen metric,\r\n- exposes a unified API: `.fit(y[, X])` and `.predict(h)`.\r\n\r\n### AutoNEO\r\n\r\n```python\r\nfrom randomstatsmodels import AutoNEO\r\n\r\nneo = AutoNEO(\r\n    param_grid={\"n_components\": [8, 16, 32]},\r\n    metric=\"mae\",\r\n)\r\nneo.fit(y)\r\nprint(\"Best params:\", neo.best_params_)\r\nprint(\"Prediction:\", neo.predict(h))\r\n```\r\n\r\n### AutoFourier\r\n\r\n```python\r\nfrom randomstatsmodels import AutoFourier\r\n\r\nfourier = AutoFourier(\r\n    param_grid={\"season_length\": [12, 24], \"n_terms\": [3, 5]},\r\n    metric=\"smape\",\r\n)\r\nfourier.fit(y)\r\nprint(\"Prediction:\", fourier.predict(h))\r\n```\r\n\r\n### AutoKNN\r\n\r\n```python\r\nfrom randomstatsmodels import AutoKNN\r\n\r\nknn = AutoKNN(\r\n    param_grid={\"k\": [3, 5, 7], \"window\": [12, 24]},\r\n    metric=\"rmse\",\r\n)\r\nknn.fit(y)\r\nprint(\"Prediction:\", knn.predict(h))\r\n```\r\n\r\n### AutoPolymath\r\n\r\n```python\r\nfrom randomstatsmodels import AutoPolymath\r\n\r\npoly = AutoPolymath(\r\n    param_grid={\"degree\": [2, 3], \"ridge\": [0.0, 0.1]},\r\n    metric=\"mae\",\r\n)\r\npoly.fit(y)\r\nprint(\"Prediction:\", poly.predict(h))\r\n```\r\n\r\n### AutoThetaAR\r\n\r\n```python\r\nfrom randomstatsmodels import AutoThetaAR\r\n\r\ntheta = AutoThetaAR(\r\n    param_grid={\"theta\": [0.5, 1.0, 2.0]},\r\n    metric=\"mape\",\r\n)\r\ntheta.fit(y)\r\nprint(\"Prediction:\", theta.predict(h))\r\n```\r\n\r\n### AutoHybridForecaster\r\n\r\n```python\r\nfrom randomstatsmodels import AutoHybridForecaster\r\n\r\nhybrid = AutoHybridForecaster(\r\n    candidate_fourier=(0, 3, 6),\r\n    candidate_trend=(0, 1),\r\n    candidate_ar=(0, 3, 5),\r\n    candidate_hidden=(8, 16, 32),\r\n)\r\nhybrid.fit(y)\r\nprint(\"Best config:\", hybrid.best_config)\r\nprint(\"Prediction:\", hybrid.predict(h))\r\n```\r\n\r\n### AutoMELD\r\n\r\n```python\r\nfrom randomstatsmodels import AutoMELD\r\n\r\nmeld = AutoMELD(\r\n    lags_grid=(8, 12),\r\n    scales_grid=((1, 3, 7), (1, 2, 4, 8)),\r\n    rff_features_grid=(64, 128),\r\n)\r\nmeld.fit(y)\r\nprint(\"Best config:\", meld.best_[\"config\"])\r\nprint(\"Prediction:\", meld.predict(h))\r\n```\r\n\r\n### AutoPALF\r\n\r\n```python\r\nfrom randomstatsmodels import AutoPALF\r\n\r\npalf = AutoPALF(\r\n    p_candidates=(4, 8, 12),\r\n    penalties=(\"huber\", \"l2\"),\r\n)\r\npalf.fit(y)\r\nprint(\"Validation score:\", palf.best_[\"val_score\"])\r\nprint(\"Prediction:\", palf.predict(h))\r\n```\r\n\r\n---\r\n\r\n## Metrics\r\n\r\nAvailable out of the box:\r\n\r\n```python\r\nfrom randomstatsmodels.metrics import mae, mse, rmse, mape, smape\r\n```\r\n\r\n---\r\n\r\n## License\r\n\r\nMIT \u00a9 2025 Jacob Wright\r\n",
    "bugtrack_url": null,
    "license": "MIT License\r\n        \r\n        Copyright (c) 2025 Jacob\r\n        \r\n        Permission is hereby granted, free of charge, to any person obtaining a copy\r\n        of this software and associated documentation files (the \"Software\"), to deal\r\n        in the Software without restriction, including without limitation the rights\r\n        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n        copies of the Software, and to permit persons to do so, subject to the following\r\n        conditions:\r\n        \r\n        The above copyright notice and this permission notice shall be included in\r\n        all copies or substantial portions of the Software.\r\n        \r\n        THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r\n        SOFTWARE.",
    "summary": "Tools for benchmarking, metrics, and models.",
    "version": "1.1.2",
    "project_urls": null,
    "split_keywords": [
        "statistics",
        " metrics",
        " machine-learning",
        " forecasting",
        " evaluation",
        " error-metrics",
        " model-selection",
        " time-series",
        " analysis"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "127baefc30260795bbb881e64bfd34dcdedfc08476dbd22047552873ae329f2d",
                "md5": "8f03d0e3ddb23f9794c3f6ae6e362cde",
                "sha256": "517cc9e595ae1417a26bc2fb8361244bf871f646fbf29db4653e5a90d478b95f"
            },
            "downloads": -1,
            "filename": "randomstatsmodels-1.1.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "8f03d0e3ddb23f9794c3f6ae6e362cde",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 50425,
            "upload_time": "2025-08-29T18:37:56",
            "upload_time_iso_8601": "2025-08-29T18:37:56.677463Z",
            "url": "https://files.pythonhosted.org/packages/12/7b/aefc30260795bbb881e64bfd34dcdedfc08476dbd22047552873ae329f2d/randomstatsmodels-1.1.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "e9e9b07e4a1126bb7e2f6daa293c077efb085a929f82c2b1029f7db749462bb3",
                "md5": "40aa72d69e0cbb2cb553a611f086c022",
                "sha256": "34187b00f97adabbb204b7dba4dd193853c588220c7921c08b55d02c87f55f84"
            },
            "downloads": -1,
            "filename": "randomstatsmodels-1.1.2.tar.gz",
            "has_sig": false,
            "md5_digest": "40aa72d69e0cbb2cb553a611f086c022",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 42349,
            "upload_time": "2025-08-29T18:37:57",
            "upload_time_iso_8601": "2025-08-29T18:37:57.815082Z",
            "url": "https://files.pythonhosted.org/packages/e9/e9/b07e4a1126bb7e2f6daa293c077efb085a929f82c2b1029f7db749462bb3/randomstatsmodels-1.1.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-29 18:37:57",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "randomstatsmodels"
}
        
Elapsed time: 1.24137s