No project description provided
Project description
This repo is an implementation of stochastic linear unmixing using pytorch.
It is a fast and efficient, and can unmix even if there are null values.
$H$ is a 2d metrix, each row in it is a single end member.
Each column is a single feature of the end members.
No null values are allowed in $H$.
$O$ is a 2d metrix, each row a single observed instance.
The columns of $O$ are the same as the columns of $H$.
Null values are allowed in $O$.
The main class of this repo, LinearUnmixing, is calculating $R$ matrix
that minimizes the loss between $O$ and $H \cdot R$.
$R$ is constrained to be non-negative and each row in R sums to 1.
Reconstruction error can be used for filtering, since there is no
assessment for $R$, but we can asses the distance between $O$ and $H \cdot R$.
requirements:
numpy
torch
Installation:
pip install unmixing
Usage example:
n_endmembers = 5
n_features = 4
n_rows = 1_000
endmembers = torch.randint(1, 10, (n_endmembers, n_features), dtype=torch.float32)
non_negative = torch.randn((n_rows, n_endmembers)) ** 2
rates = non_negative / non_negative.sum(axis=1).reshape((-1, 1))
observed = torch.matmul(rates, endmembers)
lm = LinearUnmixing(endmembers, observed)
lm.unmix()
pred_rates = lm.get_rates()
rates_errors = (pred_rates - rates.numpy()).sum(axis=1).round(2)
print(f"first example - max rate error: {rates_errors.max()}")
reconstruction_error_per_observation = lm.get_errors()
print(f"first example - mean absolute reconstruction error: "
f"{np.mean(np.abs(reconstruction_error_per_observation))}")
detailed_reconstruction_error = lm.get_errors_per_column()
print(f"first example - mean absolute reconstruction error per entry: "
f"{np.mean(np.abs(detailed_reconstruction_error))}")
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file unmixing-0.2.0.tar.gz.
File metadata
- Download URL: unmixing-0.2.0.tar.gz
- Upload date:
- Size: 4.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.7.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
147eca9be8757e794982cd35b83f8772dd2ec9f663679bc1be8a4fefbe30d6cb
|
|
| MD5 |
f787be5da105bf1f0e562ddc1c916efc
|
|
| BLAKE2b-256 |
1b059a14890473b3bb91e25824eead9678ed80a2ff0a858a5a99a00390e29370
|
File details
Details for the file unmixing-0.2.0-py3-none-any.whl.
File metadata
- Download URL: unmixing-0.2.0-py3-none-any.whl
- Upload date:
- Size: 4.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.7.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5dbb46926f635b3848ec32b620614ae8f6c294879ce6094eda617e4dda077b9d
|
|
| MD5 |
1e6cb9d714635da5e2aa9b6e174ed8c8
|
|
| BLAKE2b-256 |
d2858daac6f2308652da5b16bdd705f8885e3ca2db0bb14412827bdf693d1703
|