A collection of useful functions/classes for data analysis and ML.
Project description
wutils
A collection of Python utility functions/classes.
Currently only provides one class: wutils.mat.MarkedMatrix
, which is a wrapper around a numpy.array
with additional row labels and helper functions.
Can be installed with pip install wutils
.
Example
import numpy as np
import matplotlib.pyplot as plt
from wutils.mat import MarkedMatrix
# Create a MarkedMatrix from a tuple of label-matrix tuples
mm = MarkedMatrix((
('a', np.random.randn(100, 100)),
('b', np.random.randn(50, 100)) # num. of columns must match 'a'
))
# Create a labeled TSNE plot of the components
plt.figure()
mm.tsne()
plt.show()
# Perform SVD on the full matrix
U, _, _ = np.linalg.svd(mm.get_mat(), full_matrices=False)
# Form another MarkedMatrix consisting of the first 2 columns of U.
# We reuse our existing labels
mm_U = MarkedMatrix((U[:, 2], mm.get_loc_idx()))
# Split up the MarkedMatrix to an OrderedDict of label to submatrix
print(mm_U.get_pieces())
# Output:
# OrderedDict([
# ('a', array([...])),
# ('b', array([...]))
# ])
# where 'a' is 100 x 2
# and 'b' is 50 x 2
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
wutils-0.2.3-py3-none-any.whl
(11.2 kB
view details)
File details
Details for the file wutils-0.2.3-py3-none-any.whl
.
File metadata
- Download URL: wutils-0.2.3-py3-none-any.whl
- Upload date:
- Size: 11.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.63.0 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 51a56514730addf601c7447d14c71b90180febf64db4f5eb38c1468fd3a762f5 |
|
MD5 | 1e3889f346e21a1463763974361ba930 |
|
BLAKE2b-256 | 4501fa799bfdf46c50c7fdd9c940d0c91463b7905aaa0c3099222aeefd5216ca |