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.1.tar.gz (197.7 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.1-py3-none-any.whl (17.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pcurvepy2-0.2.1.tar.gz
Algorithm Hash digest
SHA256 a49f026e939f3e4cffd04f807674f0d850c30108297baaf9621598d13f231cc2
MD5 8775d9e5a7345ccbda1375614e9ad677
BLAKE2b-256 b32c02fad96d9d84e2aa6651726e13445e3ff02d5746e2bd24127024e9f68c2f

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for pcurvepy2-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b54983c2c8e967f18931172a5bb327c23a5480aafb4a5dc8c3abe6ae06c5cb7f
MD5 74d82e38cc1e652fe633650c91b8b786
BLAKE2b-256 1ca9bbb583f5e18a563fcb4f204be97ea482c4092d5edefcd0af8720f2ad55f4

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