matlab校园行 上海科技大学 -...
TRANSCRIPT
1© 2016 The MathWorks, Inc.
MATLAB校园行上海科技大学
2© 2016 The MathWorks, Inc.
MATLAB数据分析实践
卓金武
MathWorks
3
讲师简介
卓金武
高级工程师,大学计划经理
技术领域:数据分析、优化、数据挖掘、量化投资等MATLAB
科学计算方向
获奖情况:2次获全国大学生数学建模竞赛一等奖 (2003, 2004),1次获全国研究生数学建模竞赛一等奖 (2007);
著作:《MATLAB在数学建模中的应用》(第1,2版)《量化投资——MATLAB数据挖掘技术与实践》《大数据挖掘:系统方法与实例分析》
4
MathWorks®
5
MathWorks是领先的为工程师和科学家提供数学计算软件的供应商。公司于1984 年创立,总部位于美国马萨诸塞州内迪克,在全球 15 个国家有 3500 名员工
6
Headquarters:
Natick, Massachusetts USA
Other US Locations:
California, Michigan,
Texas, Washington DC
Europe:
France, Germany, Italy,
Spain, the Netherlands,
Sweden, Switzerland, UK
Asia-Pacific:
Australia, China, India,
Japan, Korea
Worldwide training
and consulting
Distributors in 25 countries
Earth’s topography on an equidistant cylindrical projection,
created with MATLAB® and Mapping Toolbox™.
MathWorks®
7
SIMULINK仿真以及基于模型设计
MATLAB科学计算语言
数学,统计,优化
应用程序 数据库和报告
快速原型与HIL仿真
验证、确认和测试
仿真图示和报告
基于事件的建模 物理建模
代码生成并行计算
控制系统
信号处理和通讯
图像和视频处理
测试测量
金融计算
生物计算
应用
MATLAB 家族
基于 MATLAB 和 Simulink 的近百种工具箱和扩展模块 正应用于当下的各行各业
8
内容提要
MATLAB高效编程技巧
MATLAB 数据分析流程
MATLAB 常用数据分析方法
数据分析实践
9
MATLAB量化投资入门实例-股票的评价
• 方法:
– 将股票的数据导入MATLAB
– 交互式地探索数据并确定评估股票的方法
– 用脚本自动实现对一只股票价值和风险的评估
• 目标: 如何来评价股票的价值和风险
10
MATLAB客户端界面
11
MATLAB科学计算流程
Reporting and
Documentation
Outputs for Design
Deployment
ShareExplore & Discover
Data Analysis
& Modeling
Algorithm
Development
Application
Development
Files
Software
Hardware
Access
Code & Applications
Automate
12
MATLAB导入数据的方法
1 右键导入数据
13
Array:
包含多个值的变量(任意长度,任意维度)
Matrix:
数值型 2-D array (m-by-n)
Vector:
1-D array (1-by-n or m-by-1)
Scalar:
单个值
MATLAB中的数据结构
14
MATLAB中的数据类型
15
数据探索
数据建模
股票评价的实现-交互式
16
获取帮助: doc/help
脚本结构: 分节 注释
借助菜单: 导入数据 绘图面板 运行/分节运行 发布功能
入门后如何提高: 以项目为载体,不断拓展外沿,积累经验、提高技能
MATLAB入门的要求:能用脚本实现某个项目或问题的解决方案
MATLAB入门要点总结
17
程序开发方式
function
script
command line
value
variable
structure
精炼并提升代码
可维护的
可重用/ 更广泛
强壮的
18
各股票的综合评价值及最佳股票
19
内容提要
MATLAB高效编程技巧
MATLAB 数据分析流程
MATLAB 常用数据分析方法
数据分析实践
20
数据分析
“Data analytics is a process of inspecting, cleaning, transforming, and modeling
data with the goal of discovering useful information, suggesting conclusions, and
supporting decision-making. ”
- - - Wikipedia
21
数据分析应用
22
MATLAB lets engineers do
Data Science
themselves
2MATLAB 使得数据分析变得简单
23
MATLAB数据分析典型工作流程
Reporting and
Documentation
Outputs for Design
Deployment
ShareExplore & Discover
Data Analysis
& Modeling
Algorithm
Development
Application
Development
Files
Software
Hardware
Access
Code & Applications
Automate
24
MATLAB支持多种数据源
文件访问• Text
• Spreadsheet
• XML
• CDF/HDF
• Image
• Audio
• Video
• Geospatial/Maps
• Web content
硬件访问• Data acquisition
• Image capture
• GPU
• Lab instruments
通信协议•CAN (Controller Area Network)
•DDS (Data Distribution Service)
•OPC (OLE for Process Control)
•XCP (eXplicit Control Protocol)
•TCP/IP
•I²C etc.
数据库访问• ODBC
• JDBC
• HDFS (Hadoop)
25
数据分析步骤
1 2 3 4 5 6 7 8 9 10 11 120
5
10
15
20
25
30
35
40
数据
统计分析
可视化
数据处理与建模
缺失值 去噪 回归
假设检验
分布率神经网
络
)sin( 654
2
321 xxxy机器学习/深度学习/数据挖掘
27
内容提要
MATLAB高效编程技巧
MATLAB 数据分析流程
MATLAB 常用数据分析方法
数据分析实践
28
数据可视化
Basic Histogram Custom Number of Bins By Group With a Normal Distribution Fit
3D Histogram Scatter Plot Pie Chart
>> load fisheriris
Box Plot
29
假设检验
130 140 150 160 170 180 190 200 2100
0.01
0.02
0.03
0.04
0.05
0.06
Height [cm]
Men
Women
ttest
ttest2
vartest
vartest2
vartestn
ztest
ttest
ttest2
ztest
>> [h,p,ci,stats] = ttest2(hmen,hwomen,0.05,'right')
ttest
ttest2
normal
distributions
testing
means
unknown
variance
comparing
two samplesttest2
30
回归方法
1990 1995 2000 2005 20103.5
4
4.5
5
5.5
6
6.5
7
Year
Con
sum
ptio
n [
106
barr
els
/day]
Data
Model
)sin( 654
2
321 xxxy
31
MATLAB机器学习
32
聚类(Clustering)
目的:
对未标记数据根据选定的特征进行分组;
33
回归(Regression)
目标:
确定多个变量之间的依赖关系。
34
分类(Classification)
目标:
利用有标签的数据训练一个分类模型。
35
Classification Learner
Classification Learner app是MATLAB 推出的一个新的应用程序(APP)。它囊括了MATLAB的有监督机器学习算法,并以图形化的方式实现特征选取、检查验证、模型训练以及结果评估。
2015a 推出,并加入到Statistics and Machine Learning Toolbox
R2015b加入如下功能:
– Discriminant analysis
– Dimension reduction via PCA
– Parallel coordinates plot
– Categorical predictors
R2016b增加并行计算功能
36
预测: 将训练模型集成到应用中
MODEL
PREDICTION
模型生成模型训练
CLASSIFICATION
REGRESSION
数据预处理
SUMMARY
STATISTICS
PCAFILTERS
CLUSTER
ANALYSIS
数据导入 数据预处理
SUMMARY
STATISTICS
PCAFILTERS
CLUSTER
ANALYSIS
NEW
DATA
分类分析工作流程
训练: 迭代训练,直到获得满意结果
37
内容提要
MATLAB高效编程技巧
MATLAB 数据分析流程
MATLAB 常用数据分析方法
数据分析实践
MATLAB2017a新功能
38
数据:数据取自100个同种型号发动机多个传感器的数据
工程背景:
执行计划式维护
依然有故障发生
已收集了故障记录以及这些故障发生前的传感器的数据
能预测出故障还有多久就会发生吗
Data provided by NASA PCoEhttp://ti.arc.nasa.gov/tech/dash/pcoe/prognostic-data-repository/
案例:涡轮发动机的预测性维护
39
?
His
tori
cal
Liv
e
Engine1
Engine2
Engine100
Initial Use/
Prior Maintenance
Time
(Flights)
Engine200
Recording Starts Failure Maintenance
?
?
?
?
数据是如何记录的
40
.exe .lib .dll
MATLAB
Compiler SDK
MATLAB
Compiler
MATLAB
Runtime
MATLAB Coder
部署模型到产品中
41
效果演示
42
增加可用时间和安全性 更可靠
降低维护成本 更经济
优化供应链管理 更出名
预测式维护的意义
43
目标:
训练股票聚类和分类模型
数据:
股票交易数据
方法:
– 提取有效特征
– 训练模型
– 用测试数据进行测试
数据点数据点
层次聚类结果相关程度图
500 1000 1500 2000 2500 3000 3500 4000 4500
500
1000
1500
2000
2500
3000
3500
4000
4500
距离矩阵
:spearm
an
0
0.2
0.4
0.6
0.8
1
1.2
1.4
1.6
1.8
基于交易数据的量化择股
44
21111015172425 21828 7 8 6132230 1192312141627 326 920 4 529
0.5
0.6
0.7
0.8
0.9
1
数据点
距离
CPCC: 0.5406
股票的聚类结果——层次聚类 股票的分类模型——决策树
技术关键与结果
45
Steps Challenge Solution
获取、探索、分析数据 数据的多样性扩展数据支持
signal, images, financial, Textual,
geospatial, and several others formats
预处理数据 缺乏专业工具高质量数据预处理函数库
Industry-standard algorithms for Finance,
Statistics, Signal, Image processing
训练模型 周期长 可交互的APP操作流程Focus on machine learning, not programing
评估模型多种问题:
过度拟合速度-精度-复杂度
集成的最佳实践Model validation tools built into app
Rich documentation with step by step guidance
反复 灵活的架构更适合定制化的流程Complete machine learning platform
MATLAB在机器学习方面的优势和劣势
46
神经网络 : 深度学习:
深度学习 vs. 神经网络
47
目标:
训练深度学习机
方法:
– 提取有效特征
– 训练深度学习模型
– 用测试数据进行测试
案例 : 基于深度学习的图像识别
48
技术关键与结果
49
内容提要
MATLAB高效编程技巧
MATLAB 数据分析流程
MATLAB 常用数据分析方法
数据分析实践
MATLAB2017a新功能
50
MATLAB 2017a
What's New – MATLAB® Product Family
51
Regression LearnerRegression Learner App是MATLAB 2017a推出的一个新的应用程序(APP)。它囊括了MATLAB所支持的回归分析算法,并以图形化的方式实现特征选取、检查验证、模型训练以及结果评估。其同时支持如下功能:
Dimension reduction via PCA
Parallel coordinates plot
Parallel computing
52
tall arrayMATLAB 2017a中,tall array可以支持SVM、逻辑回归、随机森林等分类算法,以及套索正则化方法
53
更多学习资源
MATLAB 帮助
MathWorks 官网
MATLAB中文论坛
54© 2016 The MathWorks, Inc.© 2016 The MathWorks, Inc. MATLAB and Simulink are registered trademarks of The MathWorks, Inc. See www.mathworks.com/trademarks for
a list of additional trademarks. Other product or brand names may be trademarks or registered trademarks of their respective holders.
MATLAB
扫描右侧二维码,关注
MATLAB官方微信公众号
输入“上海科技大学”,获取本次讲座的习题,并提交答案,我们为前三位答题正确的
同学寄送精美奖品
Matlab Data Analytics源码请见:http://software.lib.shanghaitech.edu.cn/MatLab/(仅校
园网访问)