Skip to main content

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()

example

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

pcurvepy2-0.2.0.tar.gz (188.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pcurvepy2-0.2.0-py3-none-any.whl (17.1 kB view details)

Uploaded Python 3

File details

Details for the file pcurvepy2-0.2.0.tar.gz.

File metadata

  • Download URL: pcurvepy2-0.2.0.tar.gz
  • Upload date:
  • Size: 188.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.12

File hashes

Hashes for pcurvepy2-0.2.0.tar.gz
Algorithm Hash digest
SHA256 734a988dc766af027795288730c50c614e9b3766db707d565339cf50cb74f403
MD5 fe0b0374669d37e60d0a9fdf24023061
BLAKE2b-256 51abeec4697778b781d0112786ae7e057e2cd950c39a6a5403faa3ab76878ff6

See more details on using hashes here.

File details

Details for the file pcurvepy2-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: pcurvepy2-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 17.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.12

File hashes

Hashes for pcurvepy2-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8accd76f5621bdb51bf099626e51ea12e6bf33213e29023d6bf5b78f8f147a2e
MD5 aeed85cc7cb4a2ca65a5938af984d9ad
BLAKE2b-256 0409b4d41e89047ec18c5338b6e5746f8b0b4bd41c194f83566a026db28b94eb

See more details on using hashes here.

Supported by

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