24 from daal.algorithms
import pca
25 from daal.data_management
import FileDataSource, DataSourceIface
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
32 DAAL_PREFIX = os.path.join(
'..',
'data')
36 dataFileName = os.path.join(DAAL_PREFIX,
'online',
'pca_normalized.csv')
38 if __name__ ==
"__main__":
41 dataSource = FileDataSource(
42 dataFileName, DataSourceIface.doAllocateNumericTable,
43 DataSourceIface.doDictionaryFromContext
47 algorithm = pca.Online(method=pca.svdDense)
49 while(dataSource.loadDataBlock(nVectorsInBlock) == nVectorsInBlock):
51 algorithm.input.setDataset(pca.data, dataSource.getNumericTable())
57 result = algorithm.finalizeCompute()
60 printNumericTable(result.get(pca.eigenvalues),
"Eigenvalues:")
61 printNumericTable(result.get(pca.eigenvectors),
"Eigenvectors:")