48 from daal.algorithms
import pca
49 from daal.data_management
import FileDataSource, DataSourceIface
51 utils_folder = os.path.realpath(os.path.abspath(os.path.dirname(os.path.dirname(__file__))))
52 if utils_folder
not in sys.path:
53 sys.path.insert(0, utils_folder)
54 from utils
import printNumericTable
56 DAAL_PREFIX = os.path.join(
'..',
'data')
60 dataFileName = os.path.join(DAAL_PREFIX,
'online',
'pca_normalized.csv')
62 if __name__ ==
"__main__":
65 dataSource = FileDataSource(
66 dataFileName, DataSourceIface.doAllocateNumericTable,
67 DataSourceIface.doDictionaryFromContext
71 algorithm = pca.Online(method=pca.svdDense)
73 while(dataSource.loadDataBlock(nVectorsInBlock) == nVectorsInBlock):
75 algorithm.input.setDataset(pca.data, dataSource.getNumericTable())
81 result = algorithm.finalizeCompute()
84 printNumericTable(result.get(pca.eigenvalues),
"Eigenvalues:")
85 printNumericTable(result.get(pca.eigenvectors),
"Eigenvectors:")