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
# 运行后面的demo source 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 systems import daal4py as d4p
import numpy as np # let's try to use pandas' fast csv reader
try:
import pandas
read_csv = lambda f, c: pandas.read_csv(f, usecols=c, delimiter=',', header=None, dtype=np.float32).values
except:
# fall back to numpy loadtxt
read_csv = lambda f, c: np.loadtxt(f, usecols=c, delimiter=',', ndmin=2, dtype=np.float32) def main():
# input data file
infile = "./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 observation
data = 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 prediction
predict_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 above
predict_result = predict_algo.compute(pdata, train_result.model) # Prediction result provides prediction
assert(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 systems

import daal4py as d4p

import numpy as np

# let's try to use pandas' fast csv reader

try:

    import pandas

    read_csv = lambda f, c: pandas.read_csv(f, usecols=c, delimiter=',', header=None, dtype=np.float64).values

except:

    # fall back to numpy loadtxt

    read_csv = lambda f, c: np.loadtxt(f, usecols=c, delimiter=',', ndmin=2)

def main():

    # read data from file

    file = "./data/batch/covcormoments_dense.csv"

    data = read_csv(file, range(10))

    # compute

    alg = d4p.low_order_moments()

    res = alg.compute(data)

    # result provides minimum, maximum, sum, sumSquares, sumSquaresCentered,

    # mean, secondOrderRawMoment, variance, standardDeviation, variation

    assert 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 res

if __name__ == "__main__":

    res = main()

    # print results

    print("\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!')

Intel daal4py demo运行过程的更多相关文章

  1. 【ASP.NET MVC系列】浅谈ASP.NET MVC运行过程

    ASP.NET MVC系列文章 [01]浅谈Google Chrome浏览器(理论篇) [02]浅谈Google Chrome浏览器(操作篇)(上) [03]浅谈Google Chrome浏览器(操作 ...

  2. Mach-O文件格式和程序从载入到运行过程

    > 之前深入了解过.过去了一年多的时间.如今花些时间好好总结下,毕竟好记性不如烂笔头. 其次另一个目的,对于mach-o文件结构.关于动态载入信息那个数据区中,命令含义没有深刻掰扯清除,希望有同 ...

  3. JavaWeb -- Servlet运行过程 和 细节

    Servlet的运行过程 lServlet程序是由WEB服务器调用,web服务器收到客户端的Servlet访问请求后: ①Web服务器首先检查是否已经装载并创建了该Servlet的实例对象.如果是,则 ...

  4. 自己定义msi安装包的运行过程

    有时候我们须要在程序中运行还有一个程序的安装.这就须要我们去自己定义msi安装包的运行过程. 比方我要做一个安装管理程序,能够依据用户的选择安装不同的子产品.当用户选择了三个产品时,假设分别显示这三个 ...

  5. Libgdx游戏学习(1)——环境配置及demo运行

    原文: Libgdx游戏学习(1)--环境配置及demo运行 - Stars-One的杂货小窝 Libgdx游戏是基于Java的一款游戏引擎,可以发布Android,桌面端,Html,IOS等游戏,出 ...

  6. 江太公:javascript count(a)(b)(c)(d)运行过程思考

    昨天,我弟抛给我一个js的题,使用类似标题那样的调用方法计算a*b*c*d以致无穷的实现方法.思考了半天,终于理清了它的运行过程,记录于下: 函数体: <!DOCTYPE html> &l ...

  7. JAVA - JAVA编译运行过程

    Java编译原理 *.java→*.class→机器码 java编译器 (编译) → 虚拟机(解释执行) →  解释器(翻译) → 机器码 1.Java编译过程与c/c++编译过程不同 Java编译程 ...

  8. 孙鑫MFC学习笔记3:MFC程序运行过程

    1.MFC中WinMain函数的位置在APPMODUL.cpp APPMODUL.cpp中是_tWinMain,其实_tWinMain是一个宏#define _tWinMain WinMain 2.全 ...

  9. HOWTO - Basic MSI安装包在安装运行过程中如何获取完整源路径

    有朋友问到如何在一个Windows Installer安装包中获取安装包源路径,就是在安装包运行过程中动态获取*.msi所在完整路径. 这个问题分两类,如果我们的安装包只是一个*.msi安装文件,那么 ...

随机推荐

  1. java项目报错: org.springframework.beans.factory.BeanCreationException找不到mapper.xml文件

    错误代码 org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userSer ...

  2. 20145309李昊 WEB基础实践

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

  3. 20145333茹翔 Exp8 Web基础

    20145333茹翔 Exp8 Web基础 实验问题回答 (1)什么是表单 表单是一个包含表单元素的区域,表单元素是允许用户在表单中(比如:文本域.下拉列表.单选框.复选框等等)输入信息的元素,表单在 ...

  4. MySQL中查询所有数据库占用磁盘空间大小和单个库中所有表的大小的sql语句

    查询所有数据库占用磁盘空间大小的SQL语句: ,),' MB') as data_size, concat(,),'MB') as index_size from information_schema ...

  5. RHEL7--linux系统启动流程与故障排除

    一.Linux启动过程 MBR保存着系统的主引导程序(grub 446字节,分区表64字节),启动过程就是把内核加载到内存. 启动的顺序: 1.BIOS: 2.BIOS激活MBR: 3.MBR中的引导 ...

  6. win7系统远程桌面无法正常连接

    我的电脑--属性--远程设置:初步设置: 此外还需要确认服务是否开启

  7. 51nod 1003 阶乘后面0的数量

    每一个 2 与一个 5 相乘,结果就增加一个零. 所以求 n! 后面的连续零的个数,其实就是求其中相乘的数含有因子每对因子 2 与 5  的个数. 又因为从1到某个数,所含 2 的个数比 5 多,所以 ...

  8. Unity3D学习笔记(二):个体层次、绝对和局部坐标、V3平移旋转

    Directional Light:平行光源/方向性光源,用来模拟太阳光(角度只与旋转角度有关,与位置无关) Point Light:点光源,用来模拟灯泡,向四周发散光源 Spotlight:锥光源/ ...

  9. C#中的DllImport使用方法

    DllImport是System.Runtime.InteropServices命名空间下的一个属性类,其功能是提供从非托管DLL导出的函数的必要调用信息 DllImport属性应用于方法,要求最少要 ...

  10. darknet-训练自己的yolov3模型

    目录 Yolo v3的使用方法 安装darknet 训练Pascal VOC格式的数据 修改cfg文件中的voc.data 修改VOC.names 下载预训练卷积层权重 修改cfg/yolov3-vo ...