seglines


Nameseglines JSON
Version 0.0.5 PyPI version JSON
download
home_pagehttps://github.com/pgdr/seglines
SummarySegmented Least Squares
upload_time2023-03-15 09:35:09
maintainerPG Drange <Pal.Drange@uib.no>
docs_urlNone
authorPG Drange
requires_python
licenseMIT
keywords seglines
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # seglines

Compute segmented least squares for a dataset.  Probably assumes that `X = 1...N` or something.

```
$ seglines 10 data.csv --plot
opt = 70.19
segment  1:   0 (1.330)      13 (13.880)    f(x) = 1.009·x + 1.693
segment  2:  14 (1.340)      27 (14.190)    f(x) = 0.997·x + -11.887
segment  3:  28 (3.350)      41 (15.760)    f(x) = 0.987·x + -25.083
segment  4:  42 (3.420)      55 (17.630)    f(x) = 0.991·x + -37.058
segment  5:  56 (5.160)      69 (18.600)    f(x) = 0.949·x + -46.523
segment  6:  70 (3.870)      83 (17.660)    f(x) = 0.973·x + -63.211
segment  7:  84 (5.930)      97 (17.490)    f(x) = 0.977·x + -76.830
segment  8:  98 (5.210)     111 (17.590)    f(x) = 0.897·x + -82.366
segment  9: 112 (3.810)     125 (16.410)    f(x) = 0.963·x + -102.544
segment 10: 126 (16.780)    139 (3.190)     f(x) = -1.036·x + 147.696
```


## Install

`pip install seglines`

Depends only on `numpy`.  When using `--plot`, we also need `matplotlib`.


## Usage

There is a `--help` option: `seglines --help`

Use `seglines L data.csv` where `L` is the number of segments you want to segmentize into.

In case you want to generate an `L`-segmented linear dataset, use

`seglines --generate 5 10 > data.csv`

and then

`seglines 5 data.csv`

This will output the segments, e.g.

```
opt = 16.49
segment  1:  0 (0.410)      9 (10.330)    f(x) = 0.961·x + 1.355
segment  2: 10 (3.750)     19 (13.260)    f(x) = 0.987·x + -5.741
segment  3: 20 (13.530)    29 (4.210)     f(x) = -1.031·x + 33.960
segment  4: 30 (13.880)    37 (7.420)     f(x) = -0.913·x + 41.254
segment  5: 38 (5.190)     49 (14.720)    f(x) = 0.904·x + -29.629
```

To create a plot of the dataset, add `--plot`:

`seglines 5 data.csv --plot`

![plot of seglines](https://raw.githubusercontent.com/pgdr/seglines/master/assets/plot.png)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/pgdr/seglines",
    "name": "seglines",
    "maintainer": "PG Drange <Pal.Drange@uib.no>",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "seglines",
    "author": "PG Drange",
    "author_email": "Pal.Drange@uib.no",
    "download_url": "https://files.pythonhosted.org/packages/99/2d/f6ef0fb44b2766d9e3a459705ccc1d44b29d3760eddd012719765b65d72c/seglines-0.0.5.tar.gz",
    "platform": null,
    "description": "# seglines\n\nCompute segmented least squares for a dataset.  Probably assumes that `X = 1...N` or something.\n\n```\n$ seglines 10 data.csv --plot\nopt = 70.19\nsegment  1:   0 (1.330)      13 (13.880)    f(x) = 1.009\u00b7x + 1.693\nsegment  2:  14 (1.340)      27 (14.190)    f(x) = 0.997\u00b7x + -11.887\nsegment  3:  28 (3.350)      41 (15.760)    f(x) = 0.987\u00b7x + -25.083\nsegment  4:  42 (3.420)      55 (17.630)    f(x) = 0.991\u00b7x + -37.058\nsegment  5:  56 (5.160)      69 (18.600)    f(x) = 0.949\u00b7x + -46.523\nsegment  6:  70 (3.870)      83 (17.660)    f(x) = 0.973\u00b7x + -63.211\nsegment  7:  84 (5.930)      97 (17.490)    f(x) = 0.977\u00b7x + -76.830\nsegment  8:  98 (5.210)     111 (17.590)    f(x) = 0.897\u00b7x + -82.366\nsegment  9: 112 (3.810)     125 (16.410)    f(x) = 0.963\u00b7x + -102.544\nsegment 10: 126 (16.780)    139 (3.190)     f(x) = -1.036\u00b7x + 147.696\n```\n\n\n## Install\n\n`pip install seglines`\n\nDepends only on `numpy`.  When using `--plot`, we also need `matplotlib`.\n\n\n## Usage\n\nThere is a `--help` option: `seglines --help`\n\nUse `seglines L data.csv` where `L` is the number of segments you want to segmentize into.\n\nIn case you want to generate an `L`-segmented linear dataset, use\n\n`seglines --generate 5 10 > data.csv`\n\nand then\n\n`seglines 5 data.csv`\n\nThis will output the segments, e.g.\n\n```\nopt = 16.49\nsegment  1:  0 (0.410)      9 (10.330)    f(x) = 0.961\u00b7x + 1.355\nsegment  2: 10 (3.750)     19 (13.260)    f(x) = 0.987\u00b7x + -5.741\nsegment  3: 20 (13.530)    29 (4.210)     f(x) = -1.031\u00b7x + 33.960\nsegment  4: 30 (13.880)    37 (7.420)     f(x) = -0.913\u00b7x + 41.254\nsegment  5: 38 (5.190)     49 (14.720)    f(x) = 0.904\u00b7x + -29.629\n```\n\nTo create a plot of the dataset, add `--plot`:\n\n`seglines 5 data.csv --plot`\n\n![plot of seglines](https://raw.githubusercontent.com/pgdr/seglines/master/assets/plot.png)\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Segmented Least Squares",
    "version": "0.0.5",
    "split_keywords": [
        "seglines"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "992df6ef0fb44b2766d9e3a459705ccc1d44b29d3760eddd012719765b65d72c",
                "md5": "3760f38a5c7293a26b47f2e7aeaece87",
                "sha256": "54392c8598afd9c83f943b1d3dc3ce93e030e0585c6343002270ca6fb5c33fb4"
            },
            "downloads": -1,
            "filename": "seglines-0.0.5.tar.gz",
            "has_sig": false,
            "md5_digest": "3760f38a5c7293a26b47f2e7aeaece87",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 4824,
            "upload_time": "2023-03-15T09:35:09",
            "upload_time_iso_8601": "2023-03-15T09:35:09.486501Z",
            "url": "https://files.pythonhosted.org/packages/99/2d/f6ef0fb44b2766d9e3a459705ccc1d44b29d3760eddd012719765b65d72c/seglines-0.0.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-03-15 09:35:09",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "pgdr",
    "github_project": "seglines",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "seglines"
}
        
Elapsed time: 0.10807s