import os
import sys from daal.algorithms import low_order_moments
from daal.data_management import FileDataSource, DataSourceIface
from daal.data_management import (readOnly, NumericTableIface, BlockDescriptor, BlockDescriptor_Float32, BlockDescriptor_Intc, packed_mask) #utils_folder = os.path.realpath(os.path.abspath(os.path.dirname(os.path.dirname(__file__))))
#if utils_folder not in sys.path:
# sys.path.insert(0, utils_folder)
#from utils import printNumericTable dataFileName = 'covcormoments_dense.csv' def getArrayFromNumericTable(data_table):
num_rows = data_table.getNumberOfRows()
num_cols = data_table.getNumberOfColumns()
layout = data_table.getDataLayout()
data_table_dict = data_table.getDictionary()
try:
# see # https://software.intel.com/sites/products/documentation/doclib/daal/daal-user-and-reference-guides/daal_cpp_api/data__utils_8h_source.htm
# for numeral values of types
data_type = data_table_dict[0].indexType
except:
data_type = 1 # default to Float64 if data_type == 0:
block = BlockDescriptor_Float32()
elif data_type in [2, 4, 6, 8]:
block = BlockDescriptor_Intc()
else:
block = BlockDescriptor() # Use Float64 by default data_table.getBlockOfRows(0, num_rows, readOnly, block)
retValue = block.getArray()
data_table.releaseBlockOfRows(block) return retValue def printResults(res): mi = getArrayFromNumericTable(res.get(low_order_moments.minimum))
print (value of minimum:)
print (mi)
# print(res.get(low_order_moments.minimum))
# print(res.get(low_order_moments.minimum))
# print(res.get(low_order_moments.maximum))
# print(res.get(low_order_moments.sum))
# print(res.get(low_order_moments.sumSquares))
# print(res.get(low_order_moments.sumSquaresCentered))
# print(res.get(low_order_moments.mean))
# print(res.get(low_order_moments.secondOrderRawMoment))
# print(res.get(low_order_moments.variance))
# print(res.get(low_order_moments.standardDeviation))
# print(res.get(low_order_moments.variation)) if __name__ == "__main__": # Initialize FileDataSource to retrieve input data from .csv file
dataSource = FileDataSource(
dataFileName,
DataSourceIface.doAllocateNumericTable,
DataSourceIface.doDictionaryFromContext
) # Retrieve the data from input file
dataSource.loadDataBlock() # Create algorithm for computing low order moments in batch processing mode
algorithm = low_order_moments.Batch() # Set input arguments of the algorithm
algorithm.input.set(low_order_moments.data, dataSource.getNumericTable()) # Get computed low order moments
res = algorithm.compute() printResults(res)

  

python daal test的更多相关文章

  1. daal4py 随机森林模型训练mnist并保存模型给C++ daal predict使用

    # daal4py Decision Forest Classification Training example Serialization import daal4py as d4p import ...

  2. Intel daal数据预处理

    https://software.intel.com/en-us/daal-programming-guide-datasource-featureextraction-py # file: data ...

  3. Intel DAAL AI加速——神经网络

    # file: neural_net_dense_batch.py #================================================================= ...

  4. Intel DAAL AI加速——支持从数据预处理到模型预测,数据源必须使用DAAL的底层封装库

    数据源加速见官方文档(必须使用DAAL自己的库): Data Management Numeric Tables Tensors Data Sources Data Dictionaries Data ...

  5. Python中的多进程与多线程(一)

    一.背景 最近在Azkaban的测试工作中,需要在测试环境下模拟线上的调度场景进行稳定性测试.故而重操python旧业,通过python编写脚本来构造类似线上的调度场景.在脚本编写过程中,碰到这样一个 ...

  6. Python高手之路【六】python基础之字符串格式化

    Python的字符串格式化有两种方式: 百分号方式.format方式 百分号的方式相对来说比较老,而format方式则是比较先进的方式,企图替换古老的方式,目前两者并存.[PEP-3101] This ...

  7. Python 小而美的函数

    python提供了一些有趣且实用的函数,如any all zip,这些函数能够大幅简化我们得代码,可以更优雅的处理可迭代的对象,同时使用的时候也得注意一些情况   any any(iterable) ...

  8. JavaScript之父Brendan Eich,Clojure 创建者Rich Hickey,Python创建者Van Rossum等编程大牛对程序员的职业建议

    软件开发是现时很火的职业.据美国劳动局发布的一项统计数据显示,从2014年至2024年,美国就业市场对开发人员的需求量将增长17%,而这个增长率比起所有职业的平均需求量高出了7%.很多人年轻人会选择编 ...

  9. 可爱的豆子——使用Beans思想让Python代码更易维护

    title: 可爱的豆子--使用Beans思想让Python代码更易维护 toc: false comments: true date: 2016-06-19 21:43:33 tags: [Pyth ...

随机推荐

  1. 04: 打开tornado源码剖析处理过程

    目录:Tornado其他篇 01: tornado基础篇 02: tornado进阶篇 03: 自定义异步非阻塞tornado框架 04: 打开tornado源码剖析处理过程 目录: 1.1 torn ...

  2. 20145216史婧瑶《网络对抗》Web基础

    20145216史婧瑶<网络对抗>Web基础 实验问题回答 (1)什么是表单 表单在网页中主要负责数据采集功能.一个表单有三个基本组成部分: 表单标签.表单域.表单按钮. (2)浏览器可以 ...

  3. CodeForces 76A Gift - 最小生成树

    The kingdom of Olympia consists of N cities and M bidirectional roads. Each road connects exactly tw ...

  4. C++ tinyXML的使用和字符编码转换

    转载:http://jetyi.blog.51cto.com/1460128/761708/ 关于tinyxml使用的文档有很多(这篇文章就写的很好),这里仅提一下字符编码的转换问题,如果你不熟悉字符 ...

  5. AS不能在手机上现在调试软件

    这两天遇到的一个问题,(android studio2.0以上的版本),在在线调试应用的时候,将手机上的此程序卸载了,然后准备重新再AS中将这个程序推送到手机上,可是这时候发现不能推送,Log显示什么 ...

  6. neuroph Perceptron Sample

    错误: Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory     ...

  7. #网页中动态嵌入PDF文件/在线预览PDF内容#

    摘要:在web开发时我们有时会需要在线预览PDF内容,在线嵌入pdf文件: 问题1:如何网页中嵌入PDF: 在网页中: 常用的几种PDF预览代码片段如下: 代码片段1: 1 <object ty ...

  8. HDU 2089 不要62(数位dp模板题)

    http://acm.hdu.edu.cn/showproblem.php?pid=2089 题意:求区间内不包含4和连续62的数的个数. 思路: 简单的数位dp模板题.给大家推荐一个好的讲解博客.h ...

  9. 机器学习-数据可视化神器matplotlib学习之路(四)

    今天画一下3D图像,首先的另外引用一个包 from mpl_toolkits.mplot3d import Axes3D,接下来画一个球体,首先来看看球体的参数方程吧 (0≤θ≤2π,0≤φ≤π) 然 ...

  10. hdu 2586 How far away ? 带权lca

    How far away ? Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) P ...