https://github.com/zsteve/pcurvepy
Principal curves implementation (Hastie '89) in Python
https://github.com/zsteve/pcurvepy
dataviz-tools stats
Last synced: 10 months ago
JSON representation
Principal curves implementation (Hastie '89) in Python
- Host: GitHub
- URL: https://github.com/zsteve/pcurvepy
- Owner: zsteve
- License: gpl-3.0
- Created: 2020-03-27T00:43:05.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-04-01T23:43:22.000Z (about 6 years ago)
- Last Synced: 2025-07-15T02:26:29.517Z (11 months ago)
- Topics: dataviz-tools, stats
- Language: Python
- Homepage:
- Size: 279 KB
- Stars: 18
- Watchers: 2
- Forks: 13
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pcurvepy
### Principal curves implementation (Hastie '89) in Python
Installation:
```
pip install pcurvepy
```
Example:
```python
import pandas as pd
import matplotlib as mp
import matplotlib.pyplot as plt
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))
p = pcurve.PrincipalCurve(k = 5)
p.fit(x)
plt.scatter(x[:, 0], x[:, 1], alpha = 0.25, c = index)
plt.plot(p.p[:, 0], p.p[:, 1], c = 'k')
```
