Skip to main content

Matrix operations and linear algebra (mola) library for core Python

Introduction

mola is a Python library for doing algebra with matrices. It covers the basic operations such as matrix addition and multiplication, transposes, and inverse. Additionally, it has some miscellaneous data analytical tools for regression, clustering etc. It is written without any external Python libraries.

I wrote mola as a hobby project to remind myself of the linear algebra I studied in uni and to practice my Python programming. Particularly, this is an exercise in publishing my first Python library.

Getting started

Install with "pip install mola" or download the GitHub repository for a more recent version.

See main.py for examples and read the documentation.

Prerequisites

  • Python 3.x (written on Python 3.9, so that's sure to work)

Current features

  • basic matrix operations implemented (addition, multiplication, transpose, inverse)
  • matrices with labeled rows and columns
  • user-friendly wrappers for function fitting (including linear least squares regression, Tikhonov regularization, Gauss-Newton iteration for nonlinear fitting)
  • some basic matrix decompositions (QR decomposition and eigendecomposition)
  • clustering with hard k-means and fuzzy c-means and density-based clustering (see examples/visualize_clustering.py for a demonstration)

visualization of regression algorithms visualization of clustering algorithms

Classes

Matrix

Matrix is the main class of mola. In practice, the elements of the matrix are implemented with lists. Most of its functionality involves calling methods from this class.

LabeledMatrix

LabeledMatrix inherits Matrix and allows labeling of rows and columns, as well as overriding certain setter and getter functions to use those labels.

TODO:

  • checks to see if matrix is positive/negative definite/semidefinite
  • different matrix norms (only Frobenius and Euclidean norm implemented right now)
  • more decompositions (SVD)
  • user-friendly wrapper for logistic regression
  • preprocessing functions for matrix data (center and scale, e.g., z-scores)
  • example data analysis project to showcase existing features

License

MIT License

Copyright (c) 2023 Jere Lavikainen

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 whom the Software is
furnished 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.

Metadata

Release files for mola 2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mola 2.0.0
File Size Uploaded Provenance Actions
mola-2.0.0.tar.gz 24.8 kB Without provenance Details for mola-2.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mola 2.0.0
File Interpreter ABI Platform Actions
mola-2.0.0-py3-none-any.whl Python 3 none any Details for mola-2.0.0-py3-none-any.whl

Total release size: 50.2 kB

Release files / mola-2.0.0.tar.gz

Download URL mola-2.0.0.tar.gz
Size 24.8 kB
Tags Source
SHA-256 checksum
How to use checksums
4df48cc81da99fab57b5f35ee6b62ab787470b2f3bf6bcb19dc30bd1a675bb34
BLAKE2b-256 checksum
How to use checksums
dac139a59b55e486f9cbbb781b3389a6e81d64a10ea0fa03659a928d7eb1c83d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.18

Release files / mola-2.0.0-py3-none-any.whl

Download URL mola-2.0.0-py3-none-any.whl
Size 25.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7137b8f353dbac996001560a95b7fbaa2dbdb8b3934552808a0723f80974e266
BLAKE2b-256 checksum
How to use checksums
4899c734a84a1d87aa93a770a9758468a0ef2329a487d3b886a91b97bebdaa42
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.18

Security for mola 2.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page