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. SmartOS之以太网精简协议栈TinyIP

    做物联网,没有以太网怎么能行!基于Enc28j60,我们团队独立实现了以太网精简协议栈TinyIP,目前支持ARP/ICMP/TCP/UDP/DHCP,还缺一个DNS就完整了.TinyIP内置一个数据 ...

  2. bzoj 2427 软件安装 - Tarjan - 树形动态规划

    题目描述 现在我们的手头有N个软件,对于一个软件i,它要占用Wi的磁盘空间,它的价值为Vi.我们希望从中选择一些软件安装到一台磁盘容量为M计算机上,使得这些软件的价值尽可能大(即Vi的和最大). 但是 ...

  3. 入门dp总结

    写这篇博文主要是为了归纳总结一下dp的有关问题(不定期更新,暑假应该会更的快一些) 会大概讲一下思路,不会事无巨细地讲 另一篇是平时做过的一些dp题,这篇博客里面提到的题都有题解放在那边:https: ...

  4. maven 插件在线安装

    NO.1 在Eclipse中安装Maven插件安装详解 前言 本来是没打算写博客的,作为一个13年毕业的菜鸟,自认为水平太渣写不出什么好文章,但是前些日子看到一篇鼓励性质的文章说,技术人员的成长靠的就 ...

  5. apiCloud检出代码出现以下图示错误:

    问题如下: Initialized empty Git repository in H:/simlpe/.git/ 已经在 H:\simlpe 完成必要的项目初始化工作正在尝试从代码服务器获取数据.. ...

  6. JS post 数组道后台

    $("#aSave").click(function () { if ($("#TaskName").val() == "") { aler ...

  7. 【Python】【 接口自动化测试】【一】环境搭建

    1. 环境配置 我电脑Windows7 64位  +  Python2.7  + Oracle客户端 10.2 + cx_Oracle 10g Oracle客户端下载(为此我还申请个Oracle账号) ...

  8. c++ 容器元素填充(fill)

    #include <iostream> // cout #include <algorithm> // fill #include <vector> // vect ...

  9. jenkins定时构建示例

    项目:使用git+jenkins实现持续集成 开始构建 General 源码管理 我们安装的是git插件,还可以安装svn插件 我们将git路径存在这里还需要权限认证,否则会出现error 我们添加一 ...

  10. pyHook监听用户鼠标、键盘事件

    一.代码部分:获取用户输入信息,并与截图一起保存到XX目录下   # -*- coding: utf-8 -*- #   import pythoncom import pyHook    impor ...