{"id":17384548,"url":"https://github.com/pgdr/seglines","last_synced_at":"2025-03-27T21:18:31.467Z","repository":{"id":88720231,"uuid":"606068473","full_name":"pgdr/seglines","owner":"pgdr","description":null,"archived":false,"fork":false,"pushed_at":"2023-03-15T09:53:13.000Z","size":38,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-03-24T11:20:38.554Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pgdr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-02-24T14:26:43.000Z","updated_at":"2023-02-24T14:27:05.000Z","dependencies_parsed_at":null,"dependency_job_id":"38d04d02-811c-4cfe-8a0f-febd67a62590","html_url":"https://github.com/pgdr/seglines","commit_stats":{"total_commits":24,"total_committers":1,"mean_commits":24.0,"dds":0.0,"last_synced_commit":"ee523af9d106b0c5a4b116a05ffcf079e966a773"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgdr%2Fseglines","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgdr%2Fseglines/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgdr%2Fseglines/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgdr%2Fseglines/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pgdr","download_url":"https://codeload.github.com/pgdr/seglines/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245924501,"owners_count":20694731,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-16T07:45:50.310Z","updated_at":"2025-03-27T21:18:31.437Z","avatar_url":"https://github.com/pgdr.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 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·x + 1.693\nsegment  2:  14 (1.340)      27 (14.190)    f(x) = 0.997·x + -11.887\nsegment  3:  28 (3.350)      41 (15.760)    f(x) = 0.987·x + -25.083\nsegment  4:  42 (3.420)      55 (17.630)    f(x) = 0.991·x + -37.058\nsegment  5:  56 (5.160)      69 (18.600)    f(x) = 0.949·x + -46.523\nsegment  6:  70 (3.870)      83 (17.660)    f(x) = 0.973·x + -63.211\nsegment  7:  84 (5.930)      97 (17.490)    f(x) = 0.977·x + -76.830\nsegment  8:  98 (5.210)     111 (17.590)    f(x) = 0.897·x + -82.366\nsegment  9: 112 (3.810)     125 (16.410)    f(x) = 0.963·x + -102.544\nsegment 10: 126 (16.780)    139 (3.190)     f(x) = -1.036·x + 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 \u003e 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·x + 1.355\nsegment  2: 10 (3.750)     19 (13.260)    f(x) = 0.987·x + -5.741\nsegment  3: 20 (13.530)    29 (4.210)     f(x) = -1.031·x + 33.960\nsegment  4: 30 (13.880)    37 (7.420)     f(x) = -0.913·x + 41.254\nsegment  5: 38 (5.190)     49 (14.720)    f(x) = 0.904·x + -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","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpgdr%2Fseglines","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpgdr%2Fseglines","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpgdr%2Fseglines/lists"}