OptiMask: extracting the largest (non-contiguous) submatrix without NaN
Project description
OptiMask: Efficient NaN Data Removal in Python
Introduction
OptiMask is a Python package designed to facilitate the process of removing NaN (Not-a-Number) data from matrices while efficiently computing the largest (and not necessarily contiguous) submatrix without NaN values. This tool prioritizes practicality and compatibility with Numpy arrays and Pandas DataFrames.
Key Features
- Largest Submatrix without NaN: OptiMask calculates the largest submatrix without NaN, enhancing data analysis accuracy.
- Efficient Computation: With optimized computation, OptiMask provides rapid results without undue delays.
- Numpy and Pandas Compatibility: OptiMask seamlessly adapts to both Numpy and Pandas data structures.
Utilization
To employ OptiMask, install the optimask
package via pip:
pip install optimask
Usage Example
Import the OptiMask
class from the optimask
package and utilize its methods for efficient data masking:
from optimask import OptiMask
import numpy as np
# Create a matrix with NaN values
m = 120
n = 7
data = np.zeros(shape=(m, n))
data[24:72, 3] = np.nan
data[95, :5] = np.nan
# Solve for the largest submatrix without NaN values
rows, cols = OptiMask.solve(data)
# Calculate the ratio of non-NaN values in the result
coverage_ratio = len(rows) * len(cols) / data.size
# Check if there are any NaN values in the selected submatrix
has_nan_values = np.isnan(data[rows][:, cols]).any()
# Print or display the results
print(f"Coverage Ratio: {coverage_ratio:.2f}, Has NaN Values: {has_nan_values}")
# Output: Coverage Ratio: 0.85, Has NaN Values: False
Further Information
Additional details about the algorithm are available in this notebook.
Repository Link
Find more about OptiMask on GitHub.
Contributions
Contributions to the optimask
project are encouraged. For bug reports, feature requests, or code contributions, please open an issue or submit a pull request.
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 Distribution
Built Distribution
Hashes for optimask-0.1.15-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 917402129177417a592971e90997b342a547db0fee0d37b7148acdf2f63fa798 |
|
MD5 | 0201c603e69ca2bfa3a9fab663988574 |
|
BLAKE2b-256 | a25c583490210ed63907610dad5b915da45d06009d75c0cf0f63a62266a9890f |