Skip to main content

Matrix operations and linear algebra (mola) library without external dependencies

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mola-2.0.0.tar.gz (24.8 kB view details)

Uploaded Source

Built Distribution

mola-2.0.0-py3-none-any.whl (25.4 kB view details)

Uploaded Python 3

File details

Details for the file mola-2.0.0.tar.gz.

File metadata

  • Download URL: mola-2.0.0.tar.gz
  • Upload date:
  • Size: 24.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for mola-2.0.0.tar.gz
Algorithm Hash digest
SHA256 4df48cc81da99fab57b5f35ee6b62ab787470b2f3bf6bcb19dc30bd1a675bb34
MD5 25010f97e6718b48f746eac317a95753
BLAKE2b-256 dac139a59b55e486f9cbbb781b3389a6e81d64a10ea0fa03659a928d7eb1c83d

See more details on using hashes here.

File details

Details for the file mola-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: mola-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 25.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for mola-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7137b8f353dbac996001560a95b7fbaa2dbdb8b3934552808a0723f80974e266
MD5 ed7673e0f9aabc72973bf0915f5ffaa7
BLAKE2b-256 4899c734a84a1d87aa93a770a9758468a0ef2329a487d3b886a91b97bebdaa42

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page