47 from daal.algorithms
import pca
48 from daal.data_management
import FileDataSource, DataSourceIface
50 utils_folder = os.path.realpath(os.path.abspath(os.path.dirname(os.path.dirname(__file__))))
51 if utils_folder
not in sys.path:
52 sys.path.insert(0, utils_folder)
53 from utils
import printNumericTable
55 DAAL_PREFIX = os.path.join(
'..',
'data')
59 dataFileName = os.path.join(DAAL_PREFIX,
'online',
'pca_normalized.csv')
61 if __name__ ==
"__main__":
64 dataSource = FileDataSource(
65 dataFileName, DataSourceIface.doAllocateNumericTable,
66 DataSourceIface.doDictionaryFromContext
70 algorithm = pca.Online(method=pca.svdDense)
72 while(dataSource.loadDataBlock(nVectorsInBlock) == nVectorsInBlock):
74 algorithm.input.setDataset(pca.data, dataSource.getNumericTable())
80 result = algorithm.finalizeCompute()
83 printNumericTable(result.get(pca.eigenvalues),
"Eigenvalues:")
84 printNumericTable(result.get(pca.eigenvectors),
"Eigenvectors:")