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. 20145334赵文豪 WEB基础实践

    实验问题回答 1.什么是表单 表单在网页中主要负责数据采集功能 一个表单有三个基本组成部分: 表单标签 表单域:包含了文本框.密码框.隐藏域.多行文本框.复选框.单选框.下拉选择框和文件上传框等 表单 ...

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

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

  3. C++使用Socket 邮箱登录服务器验证

    转载:http://blog.csdn.net/zengraoli/article/details/36866241 转载:http://blog.csdn.net/alger_magic/artic ...

  4. Android Studio导入包

    1.复制jar包,打开工程,以project形式打开,在libs下面粘贴: 2.右键jar包,add as library.

  5. python装饰器,其实就是对闭包的使用。

    装饰器 理解装饰器要先理解闭包(在闭包中引用函数,可参考上一篇通过例子来理解闭包). 在代码运行期间动态增加功能的方式,称之为“装饰器”(Decorator). 装饰器的实质就是对闭包的使用,原函数被 ...

  6. Android Studio下载新的AVD映像把C盘给占满了

    不管你的Android SDK/Studio安装哪儿, 默认总是下载到 C:\Users\Administrator\.android ... 可以设置ANDROID_SDK_HOME 指定到新的目录 ...

  7. (转)Linux I/O 调度方法

    Linux I/O 调度方法 转自https://blog.csdn.net/theorytree/article/details/6259104 操作系统的调度有 CPU调度    CPU sche ...

  8. hihocoder 九十八周 搜索一 24点

    题目1 : 搜索一·24点 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 周末,小Hi和小Ho都在家待着. 在收拾完房间时,小Ho偶然发现了一副扑克,于是两人考虑用这副 ...

  9. dos与unix系统的格式转化

    unix 只用\n作为行结束符,而在 dos中是以\r和\n作为行结束符, 如果一个文件是在unix系统下创建,然后想在dos下使用,就要用unix2dos,如 unix2dos file 如果一个文 ...

  10. 安装cartographer

    # Build and install Cartographer. git clone https://github.com/hitcm/cartographer.git cd cartographe ...