-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathcomputeElasticPrincipalCircle.py
More file actions
41 lines (37 loc) · 1.8 KB
/
computeElasticPrincipalCircle.py
File metadata and controls
41 lines (37 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# -*- coding: utf-8 -*-
"""
Created on Mon Feb 5 13:46:32 2018
@author: Alexis Martin
"""
import computeElasticPrincipalGraph as EPG
from PCAView import PCA
import numpy as np
def computeElasticPrincipalCircle(data, NumNodes, newDim=None,
drawPCAview=True,
drawAccuracyComplexity=True, drawEnergy=True,
Lambda=0.01, Mu=0.1, ComputeMSEP=False,
MaxBlockSize=100000, TrimmingRadius=np.inf,
MaxNumberOfIterations=10, eps=0.01,
verbose=True):
NodeP = np.zeros((4, data.shape[1]))
v, u, s = PCA(data)
mn = data.mean(axis=0)
v1 = v[:, 0]/np.linalg.norm(v[:, 0])
v2 = v[:, 1]/np.linalg.norm(v[:, 1])
st1 = np.std(u[:, 0], ddof=1)
st2 = np.std(u[:, 1], ddof=1)
NodeP[0, :] = mn - np.dot(st1, v1.T) - np.dot(st2, v2.T)
NodeP[1, :] = mn - np.dot(st1, v1.T) + np.dot(st2, v2.T)
NodeP[2, :] = mn + np.dot(st1, v1.T) + np.dot(st2, v2.T)
NodeP[3, :] = mn + np.dot(st1, v1.T) - np.dot(st2, v2.T)
ed = np.array([[0, 1], [2, 3], [1, 2], [3, 0]])
return EPG.computeElasticPrincipalGraph(data, NumNodes, newDim,
drawPCAview,
drawAccuracyComplexity,
drawEnergy, Lambda,
Mu, NodeP, ed,
np.array([["bisectedge"]]),
np.array([]), ComputeMSEP,
MaxBlockSize, TrimmingRadius,
MaxNumberOfIterations, eps,
verbose)