Jun Xian Lee
Jun Xian Lee

Reputation: 13

How to turn the coordinate found from distance matrix to be positive?

import numpy as np
import matplotlib.pyplot as plt
import time
from sklearn.decomposition import PCA

t = np.random.randint(0, 50, (10, 10)) 
X = tpca = PCA(n_components=2) 
X3d = pca.fit_transform(X) 
X3d= np.round(X3d, 2) 
print (X3d)

How to turn the coordinate found from distance matrix to be positive?

Upvotes: 0

Views: 50

Answers (1)

galihif
galihif

Reputation: 444

You can use absolute, import math library and use abs(). example:

import math

distance = -40
print(abs(distance))

Output:

40

Upvotes: 1

Related Questions