26 from daal.algorithms
import covariance
27 from daal.algorithms
import pca
29 utils_folder = os.path.realpath(os.path.abspath(os.path.dirname(os.path.dirname(__file__))))
30 if utils_folder
not in sys.path:
31 sys.path.insert(0, utils_folder)
32 from utils
import printNumericTable, createSparseTable
34 DAAL_PREFIX = os.path.join(
'..',
'data')
37 dataFileName = os.path.join(DAAL_PREFIX,
'batch',
'covcormoments_csr.csv')
39 if __name__ ==
"__main__":
42 dataTable = createSparseTable(dataFileName)
45 algorithm = pca.Batch(fptype=np.float64, method=pca.correlationDense)
48 algorithm.parameter.covariance = covariance.Batch(fptype=np.float64, method=covariance.fastCSR)
51 algorithm.input.setDataset(pca.data, dataTable)
52 algorithm.parameter.resultsToCompute = pca.mean | pca.variance | pca.eigenvalue;
53 algorithm.parameter.isDeterministic =
True;
55 result = algorithm.compute()
58 printNumericTable(result.get(pca.eigenvalues),
"Eigenvalues:")
59 printNumericTable(result.get(pca.eigenvectors),
"Eigenvectors:")
60 printNumericTable(result.get(pca.means),
"Means:")
61 printNumericTable(result.get(pca.variances),
"Variances:")