{"id":19757107,"url":"https://github.com/dynamicslab/pysensors","last_synced_at":"2025-04-07T09:15:33.502Z","repository":{"id":56694415,"uuid":"260577702","full_name":"dynamicslab/pysensors","owner":"dynamicslab","description":"PySensors is a Python package for sparse sensor placement","archived":false,"fork":false,"pushed_at":"2025-03-14T01:10:57.000Z","size":7271,"stargazers_count":88,"open_issues_count":8,"forks_count":23,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-03-31T08:07:31.694Z","etag":null,"topics":["optimization-tools","sensor","sensor-placement","sensors"],"latest_commit_sha":null,"homepage":"http://python-sensors.readthedocs.io/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dynamicslab.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2020-05-01T23:24:56.000Z","updated_at":"2025-03-19T02:45:52.000Z","dependencies_parsed_at":"2023-12-21T17:16:02.802Z","dependency_job_id":"69ce7068-54f3-4888-9bf7-92cf25bae158","html_url":"https://github.com/dynamicslab/pysensors","commit_stats":{"total_commits":278,"total_committers":8,"mean_commits":34.75,"dds":"0.27338129496402874","last_synced_commit":"48971d96a9cad1c4f455494602fb732cdd415404"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dynamicslab%2Fpysensors","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dynamicslab%2Fpysensors/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dynamicslab%2Fpysensors/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dynamicslab%2Fpysensors/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dynamicslab","download_url":"https://codeload.github.com/dynamicslab/pysensors/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247622988,"owners_count":20968575,"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":["optimization-tools","sensor","sensor-placement","sensors"],"created_at":"2024-11-12T03:18:06.586Z","updated_at":"2025-04-07T09:15:33.466Z","avatar_url":"https://github.com/dynamicslab.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"PySensors\n=========\n|Build| |RTD| |PyPI| |Codecov| |Binder| |JOSS| |Zenodo|\n\n**PySensors** is a Scikit-learn style Python package for the sparse placement of sensors, either for reconstruction or classification tasks.\n\n.. contents:: Table of contents\n\nSparse sensor placement\n-----------------------\n\nSparse sensor placement concerns the problem of selecting a small subset\nof sensor or measurement locations in a way that allows one to perform\nsome task nearly as well as if one had access to measurements at *every*\nlocation.\n\nPySensors provides objects designed for the tasks of *reconstruction* and\n*classification*. See Manohar et al. (2018) for more information about\nthe PySensors approach to reconstruction problems and Brunton et al.\n(2016) for classification. de Silva et al. (2021) contains a full\nliterature review along with examples and additional tips for\nusing PySensors effectively.\n\n\nReconstruction\n^^^^^^^^^^^^^^\nReconstruction deals with predicting the values of a quantity of interest at different locations other than those where sensors are located.\nFor example, one might predict the temperature at a point in the middle of a lake based on temperature readings taken at various other positions in the lake.\n\nPySensors provides the ``SSPOR`` (Sparse Sensor Placement Optimization for Reconstruction) class to aid in the solution of reconstruction problems.\n\nTake representative examples of the types of data to be reconstructed (in this case polynomials)\n\n.. code-block:: python\n\n  x = numpy.linspace(0, 1, 1001)\n  data = numpy.vander(x, 11).T  # Create an array whose rows are powers of x\n\nfeed them to a ``SSPOR`` instance with 10 sensors, and\n\n.. code-block:: python\n\n  model = pysensors.reconstruction.SSPOR(n_sensors=10)\n  model.fit(data)\n\nUse the ``predict`` method to reconstruct a new function sampled at the chosen sensor locations:\n\n.. code-block:: python\n\n  f = numpy.abs(x[model.selected_sensors]**2 - 0.5)\n  f_pred = model.predict(f)\n\n.. figure:: docs/figures/vandermonde.png\n  :align: center\n  :alt: A plot showing the function to be reconstructed, the learned sensor locations, and the reconstruction.\n  :figclass: align-center\n\nClassification\n^^^^^^^^^^^^^^\nClassification is the problem of predicting which category an example belongs to, given a set of training data (e.g. determining whether digital photos are of dogs or cats).\nThe ``SSPOC`` (Sparse Sensor Placement Optimization for Classification) class is used to solve classification problems.\nUsers familiar with Scikit-learn will find it intuitive:\n\n.. code-block:: python\n\n  model = pysensors.classification.SSPOC()\n  model.fit(x, y)  # Learn sensor locations and fit a linear classifier\n  y_pred = model.predict(x_test[:, model.selected_sensors])  #  Get predictions\n\nSee our set of `classification examples \u003chttps://python-sensors.readthedocs.io/en/latest/examples/classification.html\u003e`__ for more information.\n\nBases\n^^^^^\nThe basis in which measurement data are represented can have a dramatic\neffect on performance. PySensors implements the three bases most commonly\nused for sparse sensor placement: raw measurements, SVD/POD/PCA modes, and random projections. Bases can be easily incorporated into ``SSPOR`` and ``SSPOC`` classes:\n\n.. code-block:: python\n\n  basis = pysensors.basis.SVD(n_basis_modes=20)\n  recon_model = pysensors.reconstruction.SSPOR(basis=basis)\n  class_model = pysensors.classification.SSPOC(basis=basis)\n\nSee `this example \u003chttps://python-sensors.readthedocs.io/en/latest/examples/basis_comparison.html\u003e`__ for further discussion of these options.\n\nInstallation\n-------------\n\nDependencies\n^^^^^^^^^^^^\nThe high-level dependencies for PySensors are Linux or macOS and Python 3.6-3.8. ``pip`` is also recommended as is makes managing PySensors' other dependencies much easier. You can install it by following the instructions `here \u003chttps://packaging.python.org/tutorials/installing-packages/#ensure-you-can-run-pip-from-the-command-line\u003e`__.\n\nPySensors has not been tested on Windows.\n\nInstalling with pip\n^^^^^^^^^^^^^^^^^^^\n\nIf you are using Linux or macOS you can install PySensors with pip from the command line/terminal:\n\n.. code-block:: bash\n\n  pip install python-sensors\n\n\n**Note:** the name you type in here **is** ``python-sensors`` and is **not** ``pysensors``.\n\nOnce you have run the line above, you are ready to get started with PySensors. Have a look at the examples in our `documentation \u003chttps://github.com/dynamicslab/pysensors#documentation\u003e`__ to see what PySensors can do.\n\nInstalling from source\n^^^^^^^^^^^^^^^^^^^^^^\nFirst clone this repository:\n\n.. code-block:: bash\n\n  git clone https://github.com/dynamicslab/pysensors.git\n\nThen, to install the package, run\n\n.. code-block:: bash\n\n  cd pysensors\n  pip install .\n\nIf you do not have pip you can instead use\n\n.. code-block:: bash\n\n  python setup.py install\n\nIf you do not have root access, you should add the ``--user`` option to the ``install`` commands above.\n\n\nFeatures\n--------\nThe primary PySensors objects are the ``SSPOR`` and ``SSPOC`` classes, which are used to choose sensor locations optimized for reconstruction and classification tasks, respectively. Other implemented objects include\n\n* ``basis`` - submodule implementing different bases in which to represent data\n\n  - ``Identity`` - use raw measurement data\n  - ``SVD`` - efficiently compute first k left singular vectors\n  - ``RandomProjection`` - Gaussian random projections of measurements\n\n* Convenience functions to aid in the analysis of error as number of sensors or basis modes are varied\n\nDocumentation\n-------------\nPySensors has a `documentation site \u003chttps://python-sensors.readthedocs.io/en/latest/index.html\u003e`__ hosted by readthedocs.\nExamples are available `online \u003chttps://python-sensors.readthedocs.io/en/latest/examples/index.html\u003e`__, as static\n`Jupyter notebooks \u003chttps://github.com/dynamicslab/pysensors/tree/master/examples\u003e`__ and as `interactive notebooks \u003chttps://gesis.mybinder.org/binder/v2/gh/dynamicslab/pysensors/654e8144e44bcdc4e481b59a36c496033ef90bf6\u003e`__. To run the example notebooks locally you should install the dependencies in ``requirements-examples.txt``:\n\n.. code-block:: bash\n\n  pip install -r requirements-examples.txt\n\nCommunity guidelines\n--------------------\n\nGetting support\n^^^^^^^^^^^^^^^\nYou may create an issue for any questions that aren't answered by the `documentation \u003chttps://python-sensors.readthedocs.io/en/latest/index.html\u003e`__ or `examples \u003chttps://python-sensors.readthedocs.io/en/latest/examples/index.html\u003e`__.\n\nContributing examples\n^^^^^^^^^^^^^^^^^^^^^\nIf you have used PySensors to solve an interesting problem, please consider submitting an example Jupyter notebook showcasing\nyour work!\n\nContributing code\n^^^^^^^^^^^^^^^^^\nWe welcome contributions to PySensors. To contribute a new feature please submit a pull request. To get started we recommend installing the packages in ``requirements-dev.txt`` via\n\n.. code-block:: bash\n\n    pip install -r requirements-dev.txt\n\nThis will allow you to run unit tests and automatically format your code. To be accepted your code should conform to PEP8 and pass all unit tests. Code can be tested by invoking\n\n.. code-block:: bash\n\n    pytest\n\nWe recommend using ``pre-commit`` to format your code. Once you have staged changes to commit\n\n.. code-block:: bash\n\n    git add path/to/changed/file.py\n\nyou can run the following to automatically reformat your staged code\n\n.. code-block:: bash\n\n    pre-commit\n\nNote that you will then need to re-stage any changes ``pre-commit`` made to your code.\n\nReporting issues or bugs\n^^^^^^^^^^^^^^^^^^^^^^^^\nIf you find a bug in the code or want to request a new feature, please open an issue.\n\nCiting PySensors\n----------------\nWe have published a short paper in the Journal of Open Source Software (JOSS). You can find the paper `here  \u003chttps://joss.theoj.org/papers/10.21105/joss.02828\u003e`__.\n\nIf you use PySensors in your work, please consider citing it using:\n\n.. code-block:: text\n\n    de Silva et al., (2021). PySensors: A Python package for sparse sensor placement. Journal of Open Source Software, 6(58), 2828, https://doi.org/10.21105/joss.02828``\n\nBibtex:\n\n.. code-block:: text\n\n  @article{de Silva2021,\n    doi = {10.21105/joss.02828},\n    url = {https://doi.org/10.21105/joss.02828},\n    year = {2021},\n    publisher = {The Open Journal},\n    volume = {6},\n    number = {58},\n    pages = {2828},\n    author = {Brian M. de Silva and Krithika Manohar and Emily Clark and Bingni W. Brunton and J. Nathan Kutz and Steven L. Brunton},\n    title = {PySensors: A Python package for sparse sensor placement},\n    journal = {Journal of Open Source Software}\n  }\n\n\nReferences\n------------\n-  de Silva, Brian M., Krithika Manohar, Emily Clark, Bingni W. Brunton,\n   Steven L. Brunton, J. Nathan Kutz.\n   \"PySensors: A Python package for sparse sensor placement.\"\n   arXiv preprint arXiv:2102.13476 (2021). `[arXiv] \u003chttps://arxiv.org/abs/2102.13476\u003e`__\n\n-  Manohar, Krithika, Bingni W. Brunton, J. Nathan Kutz, and Steven L. Brunton.\n   \"Data-driven sparse sensor placement for reconstruction: Demonstrating the\n   benefits of exploiting known patterns.\"\n   IEEE Control Systems Magazine 38, no. 3 (2018): 63-86.\n   `[DOI] \u003chttps://doi.org/10.1109/MCS.2018.2810460\u003e`__\n\n-  Brunton, Bingni W., Steven L. Brunton, Joshua L. Proctor, and J Nathan Kutz.\n   \"Sparse sensor placement optimization for classification.\"\n   SIAM Journal on Applied Mathematics 76.5 (2016): 2099-2122.\n   `[DOI] \u003chttps://doi.org/10.1137/15M1036713\u003e`__\n\n-  Clark, Emily, Travis Askham, Steven L. Brunton, and J. Nathan Kutz.\n   \"Greedy sensor placement with cost constraints.\" IEEE Sensors Journal 19, no. 7\n   (2018): 2642-2656.\n   `[DOI] \u003chttps://doi.org/10.1109/JSEN.2018.2887044\u003e`__\n\n.. |Build| image:: https://github.com/dynamicslab/pysensors/workflows/Tests/badge.svg\n    :target: https://github.com/dynamicslab/pysensors/actions?query=workflow%3ATests\n\n.. |RTD| image:: https://readthedocs.org/projects/python-sensors/badge/?version=latest\n    :target: https://python-sensors.readthedocs.io/en/latest/?badge=latest\n    :alt: Documentation Status\n\n.. |PyPI| image:: https://badge.fury.io/py/python-sensors.svg\n    :target: https://badge.fury.io/py/python-sensors\n\n.. |Codecov| image:: https://codecov.io/gh/dynamicslab/pysensors/branch/master/graph/badge.svg?token=3JE6G5GDR7\n    :target: https://codecov.io/gh/dynamicslab/pysensors\n\n.. |Binder| image:: https://mybinder.org/badge_logo.svg\n    :target: https://mybinder.org/v2/gh/dynamicslab/pysensors/master\n\n.. |JOSS| image:: https://joss.theoj.org/papers/10.21105/joss.02828/status.svg\n    :target: https://doi.org/10.21105/joss.02828\n\n.. |Zenodo| image:: https://zenodo.org/badge/260577702.svg\n    :target: https://zenodo.org/badge/latestdoi/260577702\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdynamicslab%2Fpysensors","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdynamicslab%2Fpysensors","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdynamicslab%2Fpysensors/lists"}