Principal curves implementation in Python
Project description
pcurvepy
Principal Curves
This is an implementation of the Principal Curves (Hastie '89) algorithm in Python.
It is a fork of the zsteve/pcurvepy
package where
the projection indices are selected according to our
translation of the R/C++ princurve
package.
Installation:
pip install pcurvepy2
Example:
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
import pcurve
data = pd.read_csv('test_data.csv')
x = data.loc[:, ('X1', 'X2')].to_numpy()
# transform data to have zero mean
x = x - np.mean(x, 0)
index = np.arange(0, len(x))
curve = pcurve.PrincipalCurve(k=5)
curve.fit(x)
plt.scatter(x[:, 0], x[:, 1], alpha=0.25, c=index)
plt.plot(curve.points[:, 0], curve.points[:, 1], c='k')
# get interpolation indices
pseudotime_interp, point_interp, order = curve.unpack_params()
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
pcurvepy2-0.1.5.tar.gz
(16.3 kB
view details)
Built Distribution
pcurvepy2-0.1.5-py3-none-any.whl
(16.9 kB
view details)
File details
Details for the file pcurvepy2-0.1.5.tar.gz
.
File metadata
- Download URL: pcurvepy2-0.1.5.tar.gz
- Upload date:
- Size: 16.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.6.1 CPython/3.11.4 Linux/6.2.0-37-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1dba962626b1d77e587a29601c5a56715d932e027f668fd2ef44d4236a8524b0 |
|
MD5 | 3cf9fe4c6ca12c02e1dba64dfb125421 |
|
BLAKE2b-256 | 6ae33c270e28291d966f25f5f91090c1755102beef03c4bb70b9852a6f9e9997 |
File details
Details for the file pcurvepy2-0.1.5-py3-none-any.whl
.
File metadata
- Download URL: pcurvepy2-0.1.5-py3-none-any.whl
- Upload date:
- Size: 16.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.6.1 CPython/3.11.4 Linux/6.2.0-37-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 30e0d62c5637c1b6287dfee12af33d27f6b31e01a7a1ef84c0b5e833fa47c702 |
|
MD5 | e0948f941e7723a6edada47e4c916586 |
|
BLAKE2b-256 | c5043731b42588bbfecb7cfe01692fc532a9d3e246b19935d36c55c517021408 |