50 from daal.algorithms
import covariance
51 from daal.algorithms
import pca
53 utils_folder = os.path.realpath(os.path.abspath(os.path.dirname(os.path.dirname(__file__))))
54 if utils_folder
not in sys.path:
55 sys.path.insert(0, utils_folder)
56 from utils
import printNumericTable, createSparseTable
58 DAAL_PREFIX = os.path.join(
'..',
'data')
61 dataFileName = os.path.join(DAAL_PREFIX,
'batch',
'covcormoments_csr.csv')
63 if __name__ ==
"__main__":
66 dataTable = createSparseTable(dataFileName)
69 algorithm = pca.Batch(fptype=np.float64, method=pca.correlationDense)
72 algorithm.parameter.covariance = covariance.Batch(fptype=np.float64, method=covariance.fastCSR)
75 algorithm.input.setDataset(pca.data, dataTable)
76 algorithm.parameter.resultsToCompute = pca.mean | pca.variance | pca.eigenvalue;
77 algorithm.parameter.isDeterministic =
True;
79 result = algorithm.compute()
82 printNumericTable(result.get(pca.eigenvalues),
"Eigenvalues:")
83 printNumericTable(result.get(pca.eigenvectors),
"Eigenvectors:")
84 printNumericTable(result.get(pca.means),
"Means:")
85 printNumericTable(result.get(pca.variances),
"Variances:")