daal安装(记得先安装anaconda):

git clone https://github.com/IntelPython/daal4py.git
cd daal4py
conda create -n DAAL4PY -c intel -c intel/label/test -c conda-forge python=3.6 mpich cnc tbb-devel daal daal-include cython jinja2 numpy
source activate DAAL4PY
export CNCROOT=$CONDA_PREFIX
export TBBROOT=$CONDA_PREFIX
export DAALROOT=$CONDA_PREFIX
python setup.py build_ext
python setup.py install
# 运行后面的demosource deactivate DAAL4PY # 退出

注意:安装过程较慢,耐心等待。

随机森林:

#*******************************************************************************
# Copyright 2014-2018 Intel Corporation
# All Rights Reserved.
#
# This software is licensed under the Apache License, Version 2.0 (the
# "License"), the following terms apply:
#
# You may not use this file except in compliance with the License.  You may
# obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
# See the License for the specific language governing permissions and
# limitations under the License.
#*******************************************************************************# daal4py Decision Forest Classification example for shared memory systemsimport daal4py as d4p
import numpy as np# let's try to use pandas' fast csv reader
try:import pandasread_csv = lambda f, c: pandas.read_csv(f, usecols=c, delimiter=',', header=None, dtype=np.float32).values
except:# fall back to numpy loadtxtread_csv = lambda f, c: np.loadtxt(f, usecols=c, delimiter=',', ndmin=2, dtype=np.float32)def main():# input data fileinfile = "./data/batch/df_classification_train.csv"testfile = "./data/batch/df_classification_test.csv"# Configure a training object (5 classes)train_algo = d4p.decision_forest_classification_training(5, nTrees=10, minObservationsInLeafNode=8, featuresPerNode=3, engine = d4p.engines_mt19937(seed=777),varImportance='MDI', bootstrap=True, resultsToCompute='computeOutOfBagError')# Read data. Let's use 3 features per observationdata   = read_csv(infile, range(3))labels = read_csv(infile, range(3,4))train_result = train_algo.compute(data, labels)# Traiing result provides (depending on parameters) model, outOfBagError, outOfBagErrorPerObservation and/or variableImportance# Now let's do some predictionpredict_algo = d4p.decision_forest_classification_prediction(5)# read test data (with same #features)pdata = read_csv(testfile, range(3))plabels = read_csv(testfile, range(3,4))# now predict using the model from the training abovepredict_result = predict_algo.compute(pdata, train_result.model)# Prediction result provides predictionassert(predict_result.prediction.shape == (pdata.shape[0], 1))return (train_result, predict_result, plabels)if __name__ == "__main__":(train_result, predict_result, plabels) = main()print("\nVariable importance results:\n", train_result.variableImportance)print("\nOOB error:\n", train_result.outOfBagError)print("\nDecision forest prediction results (first 10 rows):\n", predict_result.prediction[0:10])print("\nGround truth (first 10 rows):\n", plabels[0:10])print('All looks good!')

demo示例数据:

0.00125126,0.563585,8,2,
0.193304,0.808741,12,1,
0.585009,0.479873,6,1,
0.350291,0.895962,13,4,
0.82284,0.746605,11,2,
0.174108,0.858943,12,0,
0.710501,0.513535,10,2,
0.303995,0.0149846,1,2,
0.0914029,0.364452,4,0,
0.147313,0.165899,0,4,
0.988525,0.445692,7,2,
0.119083,0.00466933,0,2,
0.0089114,0.37788,4,2,
0.531663,0.571184,10,3,
0.601764,0.607166,10,4,
0.166234,0.663045,8,4,
0.450789,0.352123,5,3,
0.0570391,0.607685,8,4,
0.783319,0.802606,15,3,
0.519883,0.30195,6,2,
0.875973,0.726676,11,1,
0.955901,0.925718,15,3,
0.539354,0.142338,2,3,
0.462081,0.235328,1,2,
0.862239,0.209601,3,1,
0.779656,0.843654,15,3,
0.996796,0.999695,15,2,
0.611499,0.392438,6,0,
0.266213,0.297281,5,2,
0.840144,0.0237434,3,1,
0.375866,0.0926237,1,0,
0.677206,0.0562151,2,3,
0.00878933,0.91879,12,2,
0.275887,0.272897,5,2,
0.587909,0.691183,10,4,
0.837611,0.726493,11,1,
0.484939,0.205359,1,2,
0.743736,0.468459,6,2,
0.457961,0.949156,13,3,
0.744438,0.10828,2,2,
0.599048,0.385235,6,0,
0.735008,0.608966,10,2,
0.572405,0.361339,6,0,
0.151555,0.225105,0,3,
0.425153,0.802881,13,3,

计算均值 方差等统计特征:

#*******************************************************************************# Copyright 2014-2018 Intel Corporation# All Rights Reserved.## This software is licensed under the Apache License, Version 2.0 (the# "License"), the following terms apply:## You may not use this file except in compliance with the License.  You may# obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0## Unless required by applicable law or agreed to in writing, software# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.## See the License for the specific language governing permissions and# limitations under the License.#*******************************************************************************# daal4py low order moments example for shared memory systemsimport daal4py as d4pimport numpy as np# let's try to use pandas' fast csv readertry:import pandasread_csv = lambda f, c: pandas.read_csv(f, usecols=c, delimiter=',', header=None, dtype=np.float64).valuesexcept:# fall back to numpy loadtxtread_csv = lambda f, c: np.loadtxt(f, usecols=c, delimiter=',', ndmin=2)def main():# read data from filefile = "./data/batch/covcormoments_dense.csv"data = read_csv(file, range(10))# computealg = d4p.low_order_moments()res = alg.compute(data)# result provides minimum, maximum, sum, sumSquares, sumSquaresCentered,# mean, secondOrderRawMoment, variance, standardDeviation, variationassert res.minimum.shape == (1, data.shape[1])assert res.maximum.shape == (1, data.shape[1])assert res.sum.shape == (1, data.shape[1])assert res.sumSquares.shape == (1, data.shape[1])assert res.sumSquaresCentered.shape == (1, data.shape[1])assert res.mean.shape == (1, data.shape[1])assert res.secondOrderRawMoment.shape == (1, data.shape[1])assert res.variance.shape == (1, data.shape[1])assert res.standardDeviation.shape == (1, data.shape[1])assert res.variation.shape == (1, data.shape[1])return resif __name__ == "__main__":res = main()# print resultsprint("\nMinimum:\n", res.minimum)print("\nMaximum:\n", res.maximum)print("\nSum:\n", res.sum)print("\nSum of squares:\n", res.sumSquares)print("\nSum of squared difference from the means:\n", res.sumSquaresCentered)print("\nMean:\n", res.mean)print("\nSecond order raw moment:\n", res.secondOrderRawMoment)print("\nVariance:\n", res.variance)print("\nStandard deviation:\n", res.standardDeviation)print("\nVariation:\n", res.variation)print('All looks good!')

转载于:https://www.cnblogs.com/bonelee/p/9881478.html

Intel daal4py demo运行过程相关推荐

  1. 成功运行官方Tensorflow Android的demo的过程

    记录下运行tensorflow官方demo的过程 运行环境 windows 10 .Android Studio 3.1.4 1.在github上下载源码 https://github.com/ten ...

  2. Intel Realsense D435 当摄像头运行过程中突然USB线断开,对RuntimeError: Frame didn't arrived within 5000的异常捕获及处理

    如图,在摄像头运行过程中,摄像头突然断开,可能设备需要对异常进行捕获并处理(如摄像头重连,发出警报,发送信号给车辆让它停止前进等) 需阅读,python异常捕获及处理 191225 通过捕获所有异常, ...

  3. 移动端也能兼容的web页面制作1:MDBootstrap演示Demo运行演示

    [ 导读 ] MDBootstrap 是基于 Vue.js 开发的一套前端框架,拥有美观大气的界面效果,友好的交互体验,更棒的是对于移动端也有很好的兼容性.先给大家看下演示 demo 的运行,后面将围 ...

  4. dotnet core 应用是如何跑起来的 通过自己写一个 dotnet host 理解运行过程

    在上一篇博客是使用官方提供的 AppHost 跑起来整个 dotnet 程序.本文告诉大家在 dotnet 程序运行到托管代码之前,所需要的 Native 部分的逻辑.包括如何寻找 dotnet 运行 ...

  5. WPS C++ 二次开发 Demo运行

    1.官网二次开发地址:https://open.wps.cn/docs/client/wpsLoad 2.Demo源码下载: 经过测试上述链接找不到demo源码,可通过git命令下载: git clo ...

  6. webRTC服务器搭建(基于Janus)与Demo运行

    原文网址:https://blog.csdn.net/newchenxf/article/details/110451532 转载请注明出处^^ 前言 2020年,直播带货不要太火,直播的方案基于啥? ...

  7. NVIDIA Jetson Nano主机的autoware的学习与demo运行-第1章-操作环境的搭建

    操作环境的搭建   计算机平台介绍 NVIDIA 在2019年NVIDIA GPU技术大会(GTC)上发布了Jetson Nano开发套件,这是一款售价99美元的计算机,现在可供嵌入式设计人员,研究人 ...

  8. 腾讯在线教育互动课堂——Demo调试过程记录

    官方文档地址:https://cloud.tencent.com/document/product/680/17888 "Demo调试"不像集成使用,不需要完全按照文档一步步处理, ...

  9. HI3861学习笔记(3)——编译构建和代码运行过程

    一.Ninja编译工具简介 在Unix/Linux下通常使用Make/Makefile来控制代码的编译,但是Makefile对于比较大的项目有时候会比较慢,Ninja是Google的一名程序员推出的注 ...

最新文章

  1. 2022-2028年中国聚碳酸亚丙酯(PPC)行业市场深度分析及未来趋势预测报告
  2. 基于k8s多集群隔离环境下的devops实现
  3. Python shutil.md
  4. android 抓取webview中的所有图片_如何一键提取PDF文档中的所有图片?
  5. abrels.inc.php_fckk.php
  6. pycharm上python项目的导出_pycharm项目打包成exe
  7. Linux php.ini设置date.timezone=XXX为什么不生效?
  8. html中css鼠标手势样式,CSS鼠标手势
  9. 半桥驱动器芯片 TPS28225 中文资料
  10. 华为P50/P50Pro怎么解锁huawei P50pro屏幕锁开机锁激活设备锁了应该如何强制解除鸿蒙系统刷机解锁方法流程步骤不开机跳过锁屏移除锁定进系统方法经验
  11. c51为啥要宏定义时钟_C51 程序中 #define 宏定义语句末尾一定要使用分号才能正确编译通过。_学小易找答案...
  12. 在网页中加入“加载中提示”的方法
  13. 矩阵直接分解法matlab,矩阵直接三角分解法
  14. DNS 工作原理是什么,域名劫持、域名欺骗、域名污染又是什么
  15. 自然语言处理--HMM.MEMM,CRF(三)
  16. Promise(一)介绍、fs读取文件、AJAX请求
  17. ICC学习——LAB2
  18. 请问我这段多线程代码为什么会死机?
  19. FPGA 学习笔记:Vivado 生成的 Bitstream bit 文件 超大的解决方法
  20. 基于CNN的花卉识别

热门文章

  1. 使用gitlab创建项目和添加成员,并提交本地代码至gitlab远程仓库
  2. php xxtea加密,PHP实现的XXTEA加密解密算法示例
  3. fetchtype 动态控制_RouterOS利用aliyun的API接口实现DDNS动态解析
  4. 网站做好后不能用手机浏览吗_企业几年前制作的网站大部分都应该被淘汰掉
  5. mic系统装java开发软件_Windows下安装MicMac
  6. android 9.0 https 适配,android9.0适配HTTPS:not permitted by network security policy'
  7. redis的五种存储类型的具体用法
  8. 零基础基于U-Net网络实战眼底图像血管提取
  9. C++ 接口(抽象类)的概念
  10. 【PAT (Advanced Level) Practice】1149 Dangerous Goods Packaging (25 分)