24 from daal.algorithms
import covariance
25 from daal.algorithms
import pca
27 utils_folder = os.path.realpath(os.path.abspath(os.path.dirname(os.path.dirname(__file__))))
28 if utils_folder
not in sys.path:
29 sys.path.insert(0, utils_folder)
30 from utils
import printNumericTable, createSparseTable
32 DAAL_PREFIX = os.path.join(
'..',
'data')
35 dataFileName = os.path.join(DAAL_PREFIX,
'batch',
'covcormoments_csr.csv')
37 if __name__ ==
"__main__":
40 dataTable = createSparseTable(dataFileName)
43 algorithm = pca.Batch(fptype=np.float64, method=pca.correlationDense)
46 algorithm.parameter.covariance = covariance.Batch(fptype=np.float64, method=covariance.fastCSR)
49 algorithm.input.setDataset(pca.data, dataTable)
50 algorithm.parameter.resultsToCompute = pca.mean | pca.variance | pca.eigenvalue;
51 algorithm.parameter.isDeterministic =
True;
53 result = algorithm.compute()
56 printNumericTable(result.get(pca.eigenvalues),
"Eigenvalues:")
57 printNumericTable(result.get(pca.eigenvectors),
"Eigenvectors:")
58 printNumericTable(result.get(pca.means),
"Means:")
59 printNumericTable(result.get(pca.variances),
"Variances:")