jina.math.dimensionality_reduction module

class jina.math.dimensionality_reduction.PCA(n_components, whiten=False)[source]

Bases: object

PCA is a class for dimensionality reduction using PCA in Jina.

Parameters
  • n_components (int) – Number of components to keep when projecting with PCA

  • whiten (bool) – Flag variable stating if there projecting with whitening

fit(x_mat)[source]

Computes the projection matrix of the PCA algorithm and stores it to self.w

Parameters

x_mat (ndarray) – Matrix of shape (n_observations, n_features)

transform(x_mat)[source]

Projects data from n_features to self.n_components features.

Parameters

x_mat (ndarray) – Matrix of shape (n_observations, n_features)

Return type

ndarray

Returns

Matrix of shape (n_observations, self.n_components)

fit_transform(x_mat)[source]

Fits the PCA and returns a transformed data :type x_mat: ndarray :param x_mat: Matrix of shape (n_observations, n_features) :rtype: ndarray :return: Matrix of shape (n_observations, self.n_components)