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. bzoj1634 / P2878 [USACO07JAN]保护花朵Protecting the Flowers

    P2878 [USACO07JAN]保护花朵Protecting the Flowers 难得的信息课......来一题水题吧. 经典贪心题 我们发现,交换两头奶牛的解决顺序,对其他奶牛所产生的贡献并 ...

  2. Idea中Maven仓库配置会自动恢复

    手头有好几个项目,关闭一个项目,打开另一个项目,发现又在重新下载jar包,打开设置一看,maven配置又恢复到了.m2下边.idea配置的maven会自动恢复吗? 答案是否定的,idea的设置有两个, ...

  3. Hive-查询结果导入到 MySQL

    step1:add jar /home/chenweidong/lib/hive-contrib-2.1.1-cdh.0.0.jar;add jar /home/chenweidong/lib/mys ...

  4. 20145310 Exp7 网络欺诈技术防范

    实验后回答问题 (1)通常在什么场景下容易受到DNS spoof攻击 局域网内最容易遭受攻击.通过DNS欺骗就可以轻松地将网址转到钓鱼网站.而我们平时最常用的局域网应该就是公共热点吧,特别是有的地方的 ...

  5. 一款简单实用的jQuery图片画廊插件

    图片画廊 今天分享一个自己实现的jQuery 图片画廊插件. 看一下效果图: 点击图片时: 在线演示地址:http://www.jr93.top/photoGallery/photoGallery.h ...

  6. linux网络编程--网络编程的基本函数介绍与使用【转】

    本文转载自:http://blog.csdn.net/yusiguyuan/article/details/17538499 我们深谙信息交流的价值,那网络中进程之间如何通信,如我们每天打开浏览器浏览 ...

  7. C# Byte[] 数组操作

    byte[] Strbyte = Encoding.GetEncoding("big5").GetBytes(str);            if (Strbyte.Length ...

  8. 【TCP/IP详解 卷一:协议】TCP定时器 小结

    前言 在有关TCP的章节中,介绍了四种定时器,它们体现了TCP的可靠性,其中最重要的 就是重传定时器了,剩下的定时器都是为了解决TCP的理解上的一些问题而设置的. 四种定时器: 2MSL定时器,出现在 ...

  9. UVa 10817 校长的烦恼

    https://vjudge.net/problem/UVA-10817 题意: 某校有m个教师和n个求职者,需讲授s个课程,已知每人的工资c和能教的课程集合,要求支付最少的工资使得每门课都至少有两名 ...

  10. HDU 2955 Robberies(0-1背包)

    http://acm.hdu.edu.cn/showproblem.php?pid=2955 题意:一个抢劫犯要去抢劫银行,给出了几家银行的资金和被抓概率,要求在被抓概率不大于给出的被抓概率的情况下, ...