73
메타 데이터 2016-09-30 Wan-Sup Cho ([email protected]) 1 (출처) IK솔루션즈(주) ppt자료를 수정함

메타데이터 - KOCWelearning.kocw.net/KOCW/document/2016/chungbuk/chowanseop/12.pdf · 개요 •R언어 – 데이터분석용으로특화된프로그래밍언어 – Arrays 혹은Matrix에대한연산들의모임

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: 메타데이터 - KOCWelearning.kocw.net/KOCW/document/2016/chungbuk/chowanseop/12.pdf · 개요 •R언어 – 데이터분석용으로특화된프로그래밍언어 – Arrays 혹은Matrix에대한연산들의모임

메타 데이터

2016-09-30 Wan-Sup Cho ([email protected]) 1

(출처) IK솔루션즈(주) ppt자료를 수정함

Page 2: 메타데이터 - KOCWelearning.kocw.net/KOCW/document/2016/chungbuk/chowanseop/12.pdf · 개요 •R언어 – 데이터분석용으로특화된프로그래밍언어 – Arrays 혹은Matrix에대한연산들의모임

메타 데이터

2016-09-30 Wan-Sup Cho ([email protected]) 2

(출처) IK솔루션즈(주) ppt자료를 수정함

Page 3: 메타데이터 - KOCWelearning.kocw.net/KOCW/document/2016/chungbuk/chowanseop/12.pdf · 개요 •R언어 – 데이터분석용으로특화된프로그래밍언어 – Arrays 혹은Matrix에대한연산들의모임

데이터 품질

2016-09-30 Wan-Sup Cho ([email protected]) 3

(출처) IK솔루션즈(주) ppt자료를 수정함

Page 4: 메타데이터 - KOCWelearning.kocw.net/KOCW/document/2016/chungbuk/chowanseop/12.pdf · 개요 •R언어 – 데이터분석용으로특화된프로그래밍언어 – Arrays 혹은Matrix에대한연산들의모임

데이터 품질

2016-09-30 Wan-Sup Cho ([email protected]) 4

(출처) IK솔루션즈(주) ppt자료를 수정함

Page 5: 메타데이터 - KOCWelearning.kocw.net/KOCW/document/2016/chungbuk/chowanseop/12.pdf · 개요 •R언어 – 데이터분석용으로특화된프로그래밍언어 – Arrays 혹은Matrix에대한연산들의모임

ETL History

• 최근 빅데이터 ETL 까지 발전함

2016-09-30 Wan-Sup Cho ([email protected]) 5

Cobol 언어

Hub 병목현상

제 4세대

빅데이터 플랫폼

빅데이터를 추출하여하둡,NoSQL 등빅데이터플랫폼으로이동시킴

Page 6: 메타데이터 - KOCWelearning.kocw.net/KOCW/document/2016/chungbuk/chowanseop/12.pdf · 개요 •R언어 – 데이터분석용으로특화된프로그래밍언어 – Arrays 혹은Matrix에대한연산들의모임

ETL 도구

• 도구들의 분류

– Major database vendors• IBM, Microsoft, Oracle

– Independent companies• Informatica – currently among market leaders

– Open source• Clover ETL

• Talend

– 국산 패키지• DataStreams

2016-09-30 Wan-Sup Cho ([email protected]) 6

Page 7: 메타데이터 - KOCWelearning.kocw.net/KOCW/document/2016/chungbuk/chowanseop/12.pdf · 개요 •R언어 – 데이터분석용으로특화된프로그래밍언어 – Arrays 혹은Matrix에대한연산들의모임

IBM

• Product name: InfoSphere DataStage

• Main claims:

– variety of data sources (almost any database, text, XML,web services)

– capable of handling data arriving in real-time

– scalability

• Unix (Linux) and Windows Platforms

2016-09-30 Wan-Sup Cho ([email protected]) 7

Page 8: 메타데이터 - KOCWelearning.kocw.net/KOCW/document/2016/chungbuk/chowanseop/12.pdf · 개요 •R언어 – 데이터분석용으로특화된프로그래밍언어 – Arrays 혹은Matrix에대한연산들의모임

IBM

• InfoSphere – product line that includes software from WebSphere and Information Server lines.

• Includes lots of other things

– application integration and transformation

– online marketing tools

– mobile, speech middleware

– business process management

– change data capture

– information analyzer

– data quality tools

2016-09-30 Wan-Sup Cho ([email protected]) 8

Page 9: 메타데이터 - KOCWelearning.kocw.net/KOCW/document/2016/chungbuk/chowanseop/12.pdf · 개요 •R언어 – 데이터분석용으로특화된프로그래밍언어 – Arrays 혹은Matrix에대한연산들의모임

IBM

• InfoSphere Federation Server

– Federated (virtual) integration: “Access and integratediverse data and content sources as if they were asingle resource - regardless of where the informationresides.”

– Integration across different relational products (db2,Oracle, SQL server)

– Integrity and accuracy guarantees

– Distributed query optimizer

– XML support

– Security strategies

– These are expensive products (>US$60K license)

2016-09-30 Wan-Sup Cho ([email protected]) 9

Page 10: 메타데이터 - KOCWelearning.kocw.net/KOCW/document/2016/chungbuk/chowanseop/12.pdf · 개요 •R언어 – 데이터분석용으로특화된프로그래밍언어 – Arrays 혹은Matrix에대한연산들의모임

IBM

• IBM’s view of data integration

– Key tasks, with associated products

– Tasks:• Connect to information (products: information server; data pub-lisher)

• Understand information (data architect, models for ... (banking,insurance, retail, telecom))

• Cleanse information (QualityStage: matching engine, cleaningrules etc)

• Transform information (DataStage)

• Deliver information (Federation Server, DataStage)

2016-09-30 Wan-Sup Cho ([email protected]) 10

Page 11: 메타데이터 - KOCWelearning.kocw.net/KOCW/document/2016/chungbuk/chowanseop/12.pdf · 개요 •R언어 – 데이터분석용으로특화된프로그래밍언어 – Arrays 혹은Matrix에대한연산들의모임

Microsoft

• Integration Services – part of SQL Server (SSIS)

– Supports multiple formats; converts everything intotabular format

– Transformations:• join, union

• sort

• aggregate

• lookup

• convert

– Has a data quality tool

– Goes beyond traditional ETL: e.g., data and text miningtools

2016-09-30 Wan-Sup Cho ([email protected]) 11

Page 12: 메타데이터 - KOCWelearning.kocw.net/KOCW/document/2016/chungbuk/chowanseop/12.pdf · 개요 •R언어 – 데이터분석용으로특화된프로그래밍언어 – Arrays 혹은Matrix에대한연산들의모임

Informatica

• Market leader – Informatica PowerCenter

• Provides support for

– migration

– synchronization

– warehousing

– cross-enterprise integration

• Works with multiple data formats

• Provides support for metadata management

• Real-time capabilities

2016-09-30 Wan-Sup Cho ([email protected]) 12

Page 13: 메타데이터 - KOCWelearning.kocw.net/KOCW/document/2016/chungbuk/chowanseop/12.pdf · 개요 •R언어 – 데이터분석용으로특화된프로그래밍언어 – Arrays 혹은Matrix에대한연산들의모임

Informatica

• Main orientation: scalar value transformations

• Functions: change data in a mapping

• Operators: create transformation expressions

• Syntax is SQL-based

• Part of it is essentially a programming language ina Java-like syntax for manipulating values.

• Roughly: looks at a portion of the source data,modifies it, and changes the target dataaccordingly.

2016-09-30 Wan-Sup Cho ([email protected]) 13

Page 14: 메타데이터 - KOCWelearning.kocw.net/KOCW/document/2016/chungbuk/chowanseop/12.pdf · 개요 •R언어 – 데이터분석용으로특화된프로그래밍언어 – Arrays 혹은Matrix에대한연산들의모임

Informatica

• DD_DELETE and DD_INSERT specify what to do withdata items.

• E.g., IIF( job=‘CEO’, DD_DELETE, DD_INSERT) says: itemswith job being CEO are marked for deleting, othersfor insertion.

• Operators:– Arithmetic

– String

– Comparisons

– Logical

– (almost) everything you can imagine

• Many functions for dealing with dates in differentformats.

2016-09-30 Wan-Sup Cho ([email protected]) 14

Page 15: 메타데이터 - KOCWelearning.kocw.net/KOCW/document/2016/chungbuk/chowanseop/12.pdf · 개요 •R언어 – 데이터분석용으로특화된프로그래밍언어 – Arrays 혹은Matrix에대한연산들의모임

Informatica

• Large number of functions

• Aggregates: AVG, COUNT, MIN, MAX, MEDIAN,PERCENTILE, STDDEV, SUM, etc.

• Character functions: CONCAT, LENGTH, TRIM, etc

• Conversion functions (e.g., TO_CHAR for Date,TO_DECIMAL, TO_FLOAT, TO_DATE)

• Date functions: ADD_TO_DATE, DATE_DIFF,DATE_COMPARE, etc

• Numerical: the usual suspects.

• Scientific: SIN, COS, TAN, etc

• Search for a value in the source: LOOKUP

• This was quick; full manual – almost 250 pages.

2016-09-30 Wan-Sup Cho ([email protected]) 15

Page 16: 메타데이터 - KOCWelearning.kocw.net/KOCW/document/2016/chungbuk/chowanseop/12.pdf · 개요 •R언어 – 데이터분석용으로특화된프로그래밍언어 – Arrays 혹은Matrix에대한연산들의모임

요약

• Complex tools; very good at transforming data values,and at working with specific formats (MS Word, Excel,PDF, UN/EDIFACT, RosettaNet, etc) and for specificindustries (finance, insurance, health)

• Much better these days at getting real-time data; verygood at bulk loading, supporting multiple formats

• Not so good:– virtual integration

– complex structural transformation

– query answering

– metadata management

• A lot of effort will be put there over the coming years

2016-09-30 Wan-Sup Cho ([email protected]) 16

Page 17: 메타데이터 - KOCWelearning.kocw.net/KOCW/document/2016/chungbuk/chowanseop/12.pdf · 개요 •R언어 – 데이터분석용으로특화된프로그래밍언어 – Arrays 혹은Matrix에대한연산들의모임

2015.02조완섭충북대학교 경영정보학과대학원 비즈니스데이터융합학과

[email protected]

R 언어

참고자료) 다음의 참고자료를 활용하였음- http://www.RDataMining.com, R and Data Mining : Examples and Case Studies, Yanchang Zhao- CRM을 위한 Big Data Analysis, 김경태- R을 이용한 데이터분석 실무, 서민구- R을 이용한 통계 프로그래밍, Jinseog Kim- http://www.rdatamining.com/

Page 18: 메타데이터 - KOCWelearning.kocw.net/KOCW/document/2016/chungbuk/chowanseop/12.pdf · 개요 •R언어 – 데이터분석용으로특화된프로그래밍언어 – Arrays 혹은Matrix에대한연산들의모임

목차

• 개요

• 데이터 탐색과 시각화

• 데이터 마이닝 실무

2016-09-30 Wan-Sup Cho ([email protected]) 18

Page 19: 메타데이터 - KOCWelearning.kocw.net/KOCW/document/2016/chungbuk/chowanseop/12.pdf · 개요 •R언어 – 데이터분석용으로특화된프로그래밍언어 – Arrays 혹은Matrix에대한연산들의모임

개요

• R언어

– 데이터분석용으로특화된프로그래밍언어

– Arrays 혹은 Matrix에대한연산들의모임

– 데이터 분석을 위한 도구들의 모임으로 SAS, SPSS, Splus등과같은상용제품들에비하여분석모듈이매우다양함

– 데이터분석결과를 display하는그래픽요소들을포함

– 프로그래밍언어로써 conditionals, loops, user-defined recursive functions, input/output facilities 등을포함

– Free, open-source software

2016-09-30 Wan-Sup Cho ([email protected]) 19

Page 20: 메타데이터 - KOCWelearning.kocw.net/KOCW/document/2016/chungbuk/chowanseop/12.pdf · 개요 •R언어 – 데이터분석용으로특화된프로그래밍언어 – Arrays 혹은Matrix에대한연산들의모임

개요

• 본 강좌에서는 R기본지식을 보유한 것을 가정하고,“R 활용 데이터 시각화와 마이닝”에 초점을 맞춤

– 데이터 분석결과 시각화

– 데이터 마이닝

– 예제 위주

• 나머지 부분은 별도의 R 강좌 활용 필요

2016-09-30 Wan-Sup Cho ([email protected]) 20

Page 21: 메타데이터 - KOCWelearning.kocw.net/KOCW/document/2016/chungbuk/chowanseop/12.pdf · 개요 •R언어 – 데이터분석용으로특화된프로그래밍언어 – Arrays 혹은Matrix에대한연산들의모임

R 패키지 설치

• R 설치

– http://www.r-project.org/

• R gui

2016-09-30 Wan-Sup Cho ([email protected]) 21

Page 22: 메타데이터 - KOCWelearning.kocw.net/KOCW/document/2016/chungbuk/chowanseop/12.pdf · 개요 •R언어 – 데이터분석용으로특화된프로그래밍언어 – Arrays 혹은Matrix에대한연산들의모임

R 패키지 설치

• 설치된 패키지와 경로 확인– search() : 기본적으로 설치된 패키지 확인

– searchpaths() : 이들 패키지들이 설치된 경로 확인

– 추가로 설치하는 패키지 확인

2016-09-30 Wan-Sup Cho ([email protected]) 22

Page 23: 메타데이터 - KOCWelearning.kocw.net/KOCW/document/2016/chungbuk/chowanseop/12.pdf · 개요 •R언어 – 데이터분석용으로특화된프로그래밍언어 – Arrays 혹은Matrix에대한연산들의모임

데이터 탐색과 시각화

• 데이터 소개 – iris– 붓꽃 데이터 iris는 setosa, versicolor, virginica 종에 대하여 꽃밭침(sepal)과 꽃잎(petal)의 길이를 관측한 데이터 (R 설치와 함께 제공)

– 크기가 작고, 이해하기가 쉬워 데이터 마이닝 책에서 널리 사용됨

2016-09-30 Wan-Sup Cho ([email protected]) 23

Sepal.Width Sepal.Length Petal.Length Petal.Width Species

꽃받침의

너비

꽃받침의

길이

꽃잎의

너비

꽃잎의

길이

붓꽃의 종류 :

setosa

versicolor

verginica

Page 24: 메타데이터 - KOCWelearning.kocw.net/KOCW/document/2016/chungbuk/chowanseop/12.pdf · 개요 •R언어 – 데이터분석용으로특화된프로그래밍언어 – Arrays 혹은Matrix에대한연산들의모임

데이터 탐색과 시각화

– Iris 데이터 샘플• 세가지 붓꽃, 각 붓꽃별로 50개 행, 총 150개의 붓꽃 정보를 저장한 파일

2016-09-30 Wan-Sup Cho ([email protected]) 24

Sepal.Width Sepal.Length Petal.Length Petal.Width Species

Page 25: 메타데이터 - KOCWelearning.kocw.net/KOCW/document/2016/chungbuk/chowanseop/12.pdf · 개요 •R언어 – 데이터분석용으로특화된프로그래밍언어 – Arrays 혹은Matrix에대한연산들의모임

데이터 탐색과 시각화

• 유용한 R 명령어들

2016-09-30 Wan-Sup Cho ([email protected]) 25

1 ~ 4사분위수

Page 26: 메타데이터 - KOCWelearning.kocw.net/KOCW/document/2016/chungbuk/chowanseop/12.pdf · 개요 •R언어 – 데이터분석용으로특화된프로그래밍언어 – Arrays 혹은Matrix에대한연산들의모임

데이터 탐색과 시각화

• Explore Multiple Variables

2016-09-30 Wan-Sup Cho ([email protected]) 26

Whether and how strongly a pair of variables are related to each other-1 <= correlation <= 1

Page 27: 메타데이터 - KOCWelearning.kocw.net/KOCW/document/2016/chungbuk/chowanseop/12.pdf · 개요 •R언어 – 데이터분석용으로특화된프로그래밍언어 – Arrays 혹은Matrix에대한연산들의모임

데이터 탐색과 시각화

• Statistics of Sepal.length of every Species

2016-09-30 Wan-Sup Cho ([email protected]) 27

- 종별로 Sepal.Length의 summary를 구하는 예

- Summary 인자 대신에 mean/max/min 등으로 변경가능

Page 28: 메타데이터 - KOCWelearning.kocw.net/KOCW/document/2016/chungbuk/chowanseop/12.pdf · 개요 •R언어 – 데이터분석용으로특화된프로그래밍언어 – Arrays 혹은Matrix에대한연산들의모임

데이터 탐색과 시각화

• Boxplot

2016-09-30 Wan-Sup Cho ([email protected]) 28

: Sepal.Length 에 대하여 종별로 boxplot를 그리기

Page 29: 메타데이터 - KOCWelearning.kocw.net/KOCW/document/2016/chungbuk/chowanseop/12.pdf · 개요 •R언어 – 데이터분석용으로특화된프로그래밍언어 – Arrays 혹은Matrix에대한연산들의모임

데이터 탐색과 시각화

2016-09-30 Wan-Sup Cho ([email protected]) 29

: Sepal.Length 에 대하여 histogram 그리기

Page 30: 메타데이터 - KOCWelearning.kocw.net/KOCW/document/2016/chungbuk/chowanseop/12.pdf · 개요 •R언어 – 데이터분석용으로특화된프로그래밍언어 – Arrays 혹은Matrix에대한연산들의모임

데이터 탐색과 시각화

2016-09-30 Wan-Sup Cho ([email protected]) 30

Sepal.Length 에 대하여 밀도 그리기

Page 31: 메타데이터 - KOCWelearning.kocw.net/KOCW/document/2016/chungbuk/chowanseop/12.pdf · 개요 •R언어 – 데이터분석용으로특화된프로그래밍언어 – Arrays 혹은Matrix에대한연산들의모임

데이터 탐색과 시각화

2016-09-30 Wan-Sup Cho ([email protected]) 31

각 species 별로 data 개수

각 species 별로 data 개수를 파이차트로 표시

Page 32: 메타데이터 - KOCWelearning.kocw.net/KOCW/document/2016/chungbuk/chowanseop/12.pdf · 개요 •R언어 – 데이터분석용으로특화된프로그래밍언어 – Arrays 혹은Matrix에대한연산들의모임

데이터 탐색과 시각화

2016-09-30 Wan-Sup Cho ([email protected]) 32

각 species 별로 data 개수를 barplot 표시

Page 33: 메타데이터 - KOCWelearning.kocw.net/KOCW/document/2016/chungbuk/chowanseop/12.pdf · 개요 •R언어 – 데이터분석용으로특화된프로그래밍언어 – Arrays 혹은Matrix에대한연산들의모임

데이터 탐색과 시각화

• A scatter plot

2016-09-30 Wan-Sup Cho ([email protected]) 33

> plot(iris$Sepal.Length, iris$Sepal.Width, col=iris$Species, pch=as.numeric(iris$Species))

점의 종류 (3가지)점의 색깔

X축 Y축

Page 34: 메타데이터 - KOCWelearning.kocw.net/KOCW/document/2016/chungbuk/chowanseop/12.pdf · 개요 •R언어 – 데이터분석용으로특화된프로그래밍언어 – Arrays 혹은Matrix에대한연산들의모임

데이터 탐색과 시각화

• A matrix of scatter plots : > pairs(iris)

2016-09-30 Wan-Sup Cho ([email protected]) 34

Page 35: 메타데이터 - KOCWelearning.kocw.net/KOCW/document/2016/chungbuk/chowanseop/12.pdf · 개요 •R언어 – 데이터분석용으로특화된프로그래밍언어 – Arrays 혹은Matrix에대한연산들의모임

데이터 탐색과 시각화

• A 3D scatter plot

2016-09-30 Wan-Sup Cho ([email protected]) 35

> library(scatterplot3d)> scatterplot3d(iris$Petal.Width, iris$Sepal.Length, iris$Sepal.Width)

Page 36: 메타데이터 - KOCWelearning.kocw.net/KOCW/document/2016/chungbuk/chowanseop/12.pdf · 개요 •R언어 – 데이터분석용으로특화된프로그래밍언어 – Arrays 혹은Matrix에대한연산들의모임

데이터 탐색과 시각화

• Parallel coordinates (평행 좌표 그림)

2016-09-30 Wan-Sup Cho ([email protected]) 36

> library(MASS)> parcoord(iris[1:4], col=iris$Species)

Page 37: 메타데이터 - KOCWelearning.kocw.net/KOCW/document/2016/chungbuk/chowanseop/12.pdf · 개요 •R언어 – 데이터분석용으로특화된프로그래밍언어 – Arrays 혹은Matrix에대한연산들의모임

데이터 탐색과 시각화

• Scatter Plot with Package ggplot2

2016-09-30 Wan-Sup Cho ([email protected]) 37

> library(ggplot2) <= R의 그래픽 패키지> qplot(Sepal.Length, Sepal.Width, data=iris, facets=Species ~.)

Page 38: 메타데이터 - KOCWelearning.kocw.net/KOCW/document/2016/chungbuk/chowanseop/12.pdf · 개요 •R언어 – 데이터분석용으로특화된프로그래밍언어 – Arrays 혹은Matrix에대한연산들의모임

데이터 탐색과 시각화

• 사례-2 : 데이터를 읽어서 그래프로 시각화하는 예제– 데이터셋 : PGA 골퍼선수

– 데이터 저장위치 : C:/tmp/R/PGA_Players_Converted.csv

• 처리과정

– csv 파일을 읽어 객체 players 에 저장한다

2016-09-30 Wan-Sup Cho ([email protected]) 38

Players Ht Wt DOB Birthplace Country Continent

Adamonis, Brad 188 98 1/16/73 Providence USA North America

Adams, Blake 191 93 8/27/75 Bartlesville USA North America

Affrunti, Joe 170 70 8/1/81 Chicago USA North America

Alker, Steven 180 66 7/28/71 Hamilton NZL Oceania

Allen, Michael 183 88 1/31/59 San Mateo USA North America

Allen, Steve 180 82 10/18/73 Melbourne AUS Oceania

Allenby, Robert 185 84 7/12/71 Melbourne AUS Oceania

> players <- read.csv("C:/tmp/R/PGA_Players_Converted.csv",+ stringsAsFactors=FALSE) <= 원본의 문자열을 factor로 자동변환 금지

sample <- read.csv("데이터이름.csv", sep=",", header=TRUE);

Page 39: 메타데이터 - KOCWelearning.kocw.net/KOCW/document/2016/chungbuk/chowanseop/12.pdf · 개요 •R언어 – 데이터분석용으로특화된프로그래밍언어 – Arrays 혹은Matrix에대한연산들의모임

데이터 탐색과 시각화

– R에서 읽어들인 데이터를 확인한다

– 한국인을 선택하여 Korean 으로 저장한다

– Korean에 대하여 키 (Ht)를 기준으로 그래프를 그린다

2016-09-30 Wan-Sup Cho ([email protected]) 39

> playersPlayers Ht Wt DOB Birthplace Country Continent1 Adamonis, Brad 188 98 1/16/73 Providence USA North America2 Adams, Blake 191 93 8/27/75 Bartlesville USA North America3 Affrunti, Joe 170 70 8/1/81 Chicago USA North America4 Alker, Steven 180 66 7/28/71 Hamilton NZL Oceania5 Allen, Michael 183 88 1/31/59 San Mateo USA North America

----- 이하 생략 ----------------------

> Korean <- subset(players, Country =="KOR")

> barplot(Korean$Ht, names.arg=Korean$Players)

Page 40: 메타데이터 - KOCWelearning.kocw.net/KOCW/document/2016/chungbuk/chowanseop/12.pdf · 개요 •R언어 – 데이터분석용으로특화된프로그래밍언어 – Arrays 혹은Matrix에대한연산들의모임

데이터 탐색과 시각화

– 시각화 결과

2016-09-30 Wan-Sup Cho ([email protected]) 40

Page 41: 메타데이터 - KOCWelearning.kocw.net/KOCW/document/2016/chungbuk/chowanseop/12.pdf · 개요 •R언어 – 데이터분석용으로특화된프로그래밍언어 – Arrays 혹은Matrix에대한연산들의모임

데이터 탐색과 시각화

2016-09-30 Wan-Sup Cho ([email protected]) 41

> par(mfrow=c(1,3), mar=c(3, 3, 3, 3))> hist(players$Ht, main="PGA Players Heights", ylim=c(0, 160),

+ xlab="cm", breaks=seq(160, 200, 1))> hist(players$Ht, main="PGA Players Heights", ylim=c(0, 160),

+ xlab="cm", breaks=seq(160, 200, 2))> hist(players$Ht, main="PGA Players Heights", ylim=c(0, 250),

+ xlab="cm", breaks=seq(160, 200, 5))

– 그래프 모양 바꾸기

160

0

250

160 200

Global Env.에서 Graphical Parameters 설정하나의 화면을 1행, 3열로 분할하여 3개의 그래프 그리기

Margin 설정

Page 42: 메타데이터 - KOCWelearning.kocw.net/KOCW/document/2016/chungbuk/chowanseop/12.pdf · 개요 •R언어 – 데이터분석용으로특화된프로그래밍언어 – Arrays 혹은Matrix에대한연산들의모임

데이터 탐색과 시각화

• 사례-3

– 물가상승률 그래프

– 데이터 : price.csv

2016-09-30 Wan-Sup Cho ([email protected]) 42

2000 550 500 50

2001 610 520 6.7

2002 600 530 6.7

2003 600 530 6.7

2004 600 650 0

2005 810 650 25

2006 850 650 25

2007 800 650 8.3

2008 900 800 15.4

2009 900 800 15.4

2010 900 800 15.4

2011 1200 900 15.4

2012 1200 900 15.4

2013 1200 900 25.7

년도 주거비 생활비 상승률

데이터 저장위치 : C:/tmp/R/price.csv

Page 43: 메타데이터 - KOCWelearning.kocw.net/KOCW/document/2016/chungbuk/chowanseop/12.pdf · 개요 •R언어 – 데이터분석용으로특화된프로그래밍언어 – Arrays 혹은Matrix에대한연산들의모임

데이터 탐색과 시각화

– 데이터 로딩과 그래프 그리기

2016-09-30 Wan-Sup Cho ([email protected]) 43

> price<-read.csv("C:/temp/price.csv", header=T, sep=",")

> plot(price$년도, price$주거비,type="s", ylim=c(-3, 1200),ann=FALSE, lwd=3, col="blue")

> par(new=T)> plot(price$년도, price$생활비, type="o", ylim=c(-3, 1200),

ann=FALSE, lwd=3, col="red")

모수 new값이 True일 경우 기존 그래프 영역에 그리고,False일 경우, 새로운 그래프 영역에 그린다.

Page 44: 메타데이터 - KOCWelearning.kocw.net/KOCW/document/2016/chungbuk/chowanseop/12.pdf · 개요 •R언어 – 데이터분석용으로특화된프로그래밍언어 – Arrays 혹은Matrix에대한연산들의모임

R 데이터 마이닝

Machine Learning & Statistical Learning,

Cluster Analysis & Finite Mixture Models,

Time Series Analysis,

Natural Language Processing,

Multivariate Statistics, and

Analysis of Spatial Data.

2016-09-30 44

Page 45: 메타데이터 - KOCWelearning.kocw.net/KOCW/document/2016/chungbuk/chowanseop/12.pdf · 개요 •R언어 – 데이터분석용으로특화된프로그래밍언어 – Arrays 혹은Matrix에대한연산들의모임

1. Decision Tree

(1) Decision Tree with R Package– 입력변수(들)의값을사용하여목표변수의값을예측하는모델생성

– R에서는다양한 classification packages지원

: rpart, rpartOrdinal, randomForest, party, tree, marginTree, maptree …

2016-09-30 Wan-Sup Cho ([email protected]) 45

Page 46: 메타데이터 - KOCWelearning.kocw.net/KOCW/document/2016/chungbuk/chowanseop/12.pdf · 개요 •R언어 – 데이터분석용으로특화된프로그래밍언어 – Arrays 혹은Matrix에대한연산들의모임

1. Decision Tree

(1) Decision Tree with Package – party 활용– Sepal.Length, Sepal.Width, Petal.Length and Petal.Width => Species예측

– Predictive models with package party (and rpart), function ctree() builds adecision tree, and predict() makes prediction for new data

– The iris data is split below into two subsets: training (70%) and test (30%)

– The random seed is set to a fixed value below to make the resultsreproducible

2016-09-30 Wan-Sup Cho ([email protected]) 46

Sepal.Length

Sepal.Width

Petal.Length

Petal.Width

Species ??

Decision Tree

Page 47: 메타데이터 - KOCWelearning.kocw.net/KOCW/document/2016/chungbuk/chowanseop/12.pdf · 개요 •R언어 – 데이터분석용으로특화된프로그래밍언어 – Arrays 혹은Matrix에대한연산들의모임

1. Decision Tree

2016-09-30 Wan-Sup Cho ([email protected]) 47

> ind[1] 1 1 1 1 2 1 1 1 1 1 1 1 1 2 1 2 1 1 1 1 1 1 1 1 1 2 1 2 2 1 1 1 1 1 1 2 1 1 2 2 1[42] 1 1 1 1 1 1 1 1 2 1 1 2 1 1 1 1 2 1 2 2 1 1 1 1 2 1 1 1 1 1 2 1 2 1 1 1 1 1 1 2 1[83] 1 1 1 2 1 1 1 2 1 2 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 2 1 2 1 1 2 2 1 1 2 2 2 2[124] 2 1 1 1 1 1 1 2 1 1 1 2 1 2 1 1 2 1 2 1 1 1 1 2 1 2 1

반복 Sampling 할 때 동일한 값으로 sampling

150개 iris 데이터로부터 70%는 trainData로 저장나머지 30%는 testData로 저장함

Page 48: 메타데이터 - KOCWelearning.kocw.net/KOCW/document/2016/chungbuk/chowanseop/12.pdf · 개요 •R언어 – 데이터분석용으로특화된프로그래밍언어 – Arrays 혹은Matrix에대한연산들의모임

1. Decision Tree

2016-09-30 Wan-Sup Cho ([email protected]) 48

Page 49: 메타데이터 - KOCWelearning.kocw.net/KOCW/document/2016/chungbuk/chowanseop/12.pdf · 개요 •R언어 – 데이터분석용으로특화된프로그래밍언어 – Arrays 혹은Matrix에대한연산들의모임

2016-09-30 Wan-Sup Cho ([email protected]) 49

> plot(iris_ctree)

Petal.Length <= 1.9=> 모두 setosa 임

Petal.Length > 1.9 이고Petal.Width > 1.7 이면=> 거의 대부분 virginica임

Page 50: 메타데이터 - KOCWelearning.kocw.net/KOCW/document/2016/chungbuk/chowanseop/12.pdf · 개요 •R언어 – 데이터분석용으로특화된프로그래밍언어 – Arrays 혹은Matrix에대한연산들의모임

1. Decision Tree

2016-09-30 Wan-Sup Cho ([email protected]) 50

> plot(iris_ctree, type="simple")

Page 51: 메타데이터 - KOCWelearning.kocw.net/KOCW/document/2016/chungbuk/chowanseop/12.pdf · 개요 •R언어 – 데이터분석용으로특화된프로그래밍언어 – Arrays 혹은Matrix에대한연산들의모임

1. Decision Tree

2016-09-30 Wan-Sup Cho ([email protected]) 51

> # predict on test data> testPred <- predict(iris_ctree, newdata = testData)> table(testPred, testData$Species)testPred setosa versicolor virginicasetosa 10 0 0versicolor 0 12 2virginica 0 0 14 오분류

Page 52: 메타데이터 - KOCWelearning.kocw.net/KOCW/document/2016/chungbuk/chowanseop/12.pdf · 개요 •R언어 – 데이터분석용으로특화된프로그래밍언어 – Arrays 혹은Matrix에대한연산들의모임

1. Decision Tree

(2) Decision Trees with Package - rpart

2016-09-30 Wan-Sup Cho ([email protected]) 52

Dataset - bodyfast

문제 : DEXfat 을 추정하는 모델 (tree) 생성

ageWaistcircHipcirc

elbowbreadthkneebreadthanthro3aanthro3banthro3canthro4

DEXfat 값은 ??

Page 53: 메타데이터 - KOCWelearning.kocw.net/KOCW/document/2016/chungbuk/chowanseop/12.pdf · 개요 •R언어 – 데이터분석용으로특화된프로그래밍언어 – Arrays 혹은Matrix에대한연산들의모임

1. Decision Tree

(2) Decision Trees with Package rpart

2016-09-30 Wan-Sup Cho ([email protected]) 53

> set.seed(1234)> ind <- sample(2, nrow(bodyfat), replace=TRUE, prob=c(0.7, 0.3))> bodyfat.train <- bodyfat[ind==1,]> bodyfat.test <- bodyfat[ind==2,]

> # train a decision tree> library(rpart)> myFormula <- DEXfat ~ age+waistcirc+hipcirc+elbowbreadth+kneebreadth> bodyfat_rpart <- rpart(myFormula, data = bodyfat.train,+ control = rpart.control(minsplit = 10))

> plot(bodyfat_rpart)> text(bodyfat_rpart, use.n=T)

Page 54: 메타데이터 - KOCWelearning.kocw.net/KOCW/document/2016/chungbuk/chowanseop/12.pdf · 개요 •R언어 – 데이터분석용으로특화된프로그래밍언어 – Arrays 혹은Matrix에대한연산들의모임

1. Decision Tree

• Decision tree

2016-09-30 Wan-Sup Cho ([email protected]) 54

waistcirc < 88.4

Page 55: 메타데이터 - KOCWelearning.kocw.net/KOCW/document/2016/chungbuk/chowanseop/12.pdf · 개요 •R언어 – 데이터분석용으로특화된프로그래밍언어 – Arrays 혹은Matrix에대한연산들의모임

1. Decision Tree

• The selected tree is used to make prediction and the predicted valuesare compared with actual labels.

• In the code below, function abline() draws a diagonal line.

• The predictions of a good model are expected to be equal or veryclose to their actual values, that is, most points should be on or closeto the diagonal line.

2016-09-30 Wan-Sup Cho ([email protected]) 55

> DEXfat_pred <- predict(bodyfat_rpart, newdata=bodyfat.test)> xlim <- range(bodyfat$DEXfat)> plot(DEXfat_pred ~ DEXfat, data=bodyfat.test, xlab="Observed",+ ylab="Predicted", ylim=xlim, xlim=xlim)> abline(a=0, b=1)

Page 56: 메타데이터 - KOCWelearning.kocw.net/KOCW/document/2016/chungbuk/chowanseop/12.pdf · 개요 •R언어 – 데이터분석용으로특화된프로그래밍언어 – Arrays 혹은Matrix에대한연산들의모임

1. Decision Tree

2016-09-30 Wan-Sup Cho ([email protected]) 56

Page 57: 메타데이터 - KOCWelearning.kocw.net/KOCW/document/2016/chungbuk/chowanseop/12.pdf · 개요 •R언어 – 데이터분석용으로특화된프로그래밍언어 – Arrays 혹은Matrix에대한연산들의모임

1. Decision Tree

• 변수 waistcirc 를 제거한 후 DEXfat 추정 트리 생성

2016-09-30 Wan-Sup Cho ([email protected]) 57

> myFormula <- DEXfat ~ age + hipcirc + elbowbreadth + kneebreadth> bodyfat_rpart <- rpart(myFormula, data = bodyfat.train,+ control = rpart.control(minsplit = 10))

> plot(bodyfat_rpart)> text(bodyfat_rpart, use.n=T)

n=6 n = 4

Page 58: 메타데이터 - KOCWelearning.kocw.net/KOCW/document/2016/chungbuk/chowanseop/12.pdf · 개요 •R언어 – 데이터분석용으로특화된프로그래밍언어 – Arrays 혹은Matrix에대한연산들의모임

2. Clustering ( k-Means )

• R은 다양한 clustering techniques을 지원함

– k-means clustering, k-medoids clustering, hierarchicalclustering, density-based clustering 등

> data(iris)> iris2<-iris> iris2$Species <- NULL> kmeans.result <- kmeans(iris2, 3)> kmeans.resultK-means clustering with 3 clusters of sizes 38, 62, 50

Cluster means:Sepal.Length Sepal.Width Petal.Length Petal.Width

1 6.850000 3.073684 5.742105 2.0710532 5.901613 2.748387 4.393548 1.4338713 5.006000 3.428000 1.462000 0.246000

Clustering vector:[1] 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3

[40] 3 3 3 3 3 3 3 3 3 3 3 2 2 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1[79] 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 2 1 1 1 1 2 1 1 1 1 1 1 2 2 1 1[118] 1 1 2 1 2 1 2 1 1 2 2 1 1 1 1 1 2 1 1 1 1 2 1 1 1 2 1 1 1 2 1 1 2

Page 59: 메타데이터 - KOCWelearning.kocw.net/KOCW/document/2016/chungbuk/chowanseop/12.pdf · 개요 •R언어 – 데이터분석용으로특화된프로그래밍언어 – Arrays 혹은Matrix에대한연산들의모임

2. Clustering ( k-Means )

2016-09-30 Wan-Sup Cho ([email protected]) 59

Within cluster sum of squares by cluster:[1] 23.87947 39.82097 15.15100

(between_SS / total_SS = 88.4 %)

Available components:

[1] "cluster" "centers" "totss" "withinss" "tot.withinss"[6] "betweenss" "size" "iter" "ifault"

> table(iris$Species, kmeans.result$cluster)

1 2 3setosa 0 0 50versicolor 2 48 0virginica 36 14 0

Page 60: 메타데이터 - KOCWelearning.kocw.net/KOCW/document/2016/chungbuk/chowanseop/12.pdf · 개요 •R언어 – 데이터분석용으로특화된프로그래밍언어 – Arrays 혹은Matrix에대한연산들의모임

2. Clustering ( k-Means )

2016-09-30 Wan-Sup Cho ([email protected]) 60

>> plot(iris2[c("Sepal.Length", "Sepal.Width")], col = kmeans.result$cluster)> points(kmeans.result$centers[,c("Sepal.Length", "Sepal.Width")], col = 1:3,+ pch = 8, cex=2)>

Page 61: 메타데이터 - KOCWelearning.kocw.net/KOCW/document/2016/chungbuk/chowanseop/12.pdf · 개요 •R언어 – 데이터분석용으로특화된프로그래밍언어 – Arrays 혹은Matrix에대한연산들의모임

3. 연관규칙

• 연관규칙

– 한 항목과 관련된 다른 항목집합을 구하는 문제 (함께 구매되는 상품집합)

– 연관규칙은 A =>B 형태로 표시되며, A가 구매되면 B도함께 구매된다는 의미임

• 지지도 (support) : 전체 거래중에서 A와 B가 함께 구매되는 비율

• 신뢰도 (confidence) : A를 구매한 거래 중에서 B까지 함께 구매한비율

– 실습 Datasets: groceries data• shopping bags, milk, vegetables, bread, soda, yogurt, water,tropical fruit, sausage, pastry, …

• Download URLhttp://www.salemmarafi.com/wp-content/uploads/2014/03/groceries.csv

2016-09-30 Wan-Sup Cho ([email protected]) 61

Page 62: 메타데이터 - KOCWelearning.kocw.net/KOCW/document/2016/chungbuk/chowanseop/12.pdf · 개요 •R언어 – 데이터분석용으로특화된프로그래밍언어 – Arrays 혹은Matrix에대한연산들의모임

3. 연관규칙

• Data 구조> inspect(Groceries[1:10])

items

1 {citrus fruit,semi-finished bread,margarine,ready soups}

2 {tropical fruit,yogurt,coffee}

3 {whole milk}

4 {pip fruit,yogurt,cream cheese ,meat spreads}

5 {other vegetables,whole milk,condensed milk,long life bakery product}

6 {whole milk,butter,yogurt,rice,abrasive cleaner}

7 {rolls/buns}

8 {other vegetables,UHT-milk,rolls/buns,bottled beer,liquor (appetizer)}

9 {pot plants}

10 {whole milk,cereals}

… (10,000 개 정도의 트랜잭션)

2016-09-30 Wan-Sup Cho ([email protected]) 62

Page 63: 메타데이터 - KOCWelearning.kocw.net/KOCW/document/2016/chungbuk/chowanseop/12.pdf · 개요 •R언어 – 데이터분석용으로특화된프로그래밍언어 – Arrays 혹은Matrix에대한연산들의모임

3. 연관규칙

2016-09-30 Wan-Sup Cho ([email protected]) 63

> install.packages("arules")# Load the libraries> library(arules)> library(arulesViz)> library(datasets)

# Load the dataset> data(Groceries)

# create frequent items (top 20)

> itemFrequencyPlot(Groceries, topN=20, type=“absolute”)

Page 64: 메타데이터 - KOCWelearning.kocw.net/KOCW/document/2016/chungbuk/chowanseop/12.pdf · 개요 •R언어 – 데이터분석용으로특화된프로그래밍언어 – Arrays 혹은Matrix에대한연산들의모임

3. 연관규칙

• 이제 연관규칙 마이닝 준비완료

– 최소 지지도와 신뢰도 설정• We set the minimum support 0.001, minimum confidence 0.8

• We then show the top 5 rules (전체 410개 rules 발견)

2016-09-30 Wan-Sup Cho ([email protected]) 64

# Get the rules> rules<-apriori(Groceries, parameter = list(supp=0.001, conf=0.8))# Show the top 5 rules, but only 2 digits> options(digits=2)> inspect(rules[1:5])

## 결과lhs rhs support confidence lift

1 {liquor, red/blush wine} => {bottled beer} 0.0019 0.90 11.22 {curd, cereals} => {whole milk} 0.0010 0.91 3.63 {yogurt, cereals} => {whole milk} 0.0017 0.81 3.24 {butter, jam} => {whole milk} 0.0010 0.83 3.35 {soups, bottled beer} => {whole milk} 0.0011 0.92 3.6

Page 65: 메타데이터 - KOCWelearning.kocw.net/KOCW/document/2016/chungbuk/chowanseop/12.pdf · 개요 •R언어 – 데이터분석용으로특화된프로그래밍언어 – Arrays 혹은Matrix에대한연산들의모임

3. 연관규칙

• 연관규칙 visualization

2016-09-30 Wan-Sup Cho ([email protected]) 65

> install.packages("arulesViz")> library(arulesViz)> plot(rules)> plot(sort(rules, by = "support")[1:20], method = "grouped")>

Page 66: 메타데이터 - KOCWelearning.kocw.net/KOCW/document/2016/chungbuk/chowanseop/12.pdf · 개요 •R언어 – 데이터분석용으로특화된프로그래밍언어 – Arrays 혹은Matrix에대한연산들의모임

3. 연관규칙

• Network Graph for Association Rules

2016-09-30 Wan-Sup Cho ([email protected]) 66

> plot(rules, method = "graph", control = list(type="items"))

원은 item이 아니라 {item} → {item} 연관규칙의 support임(원의 크기가 지지도의 크기를 나타냄)색깔은 향상도(Lift)를 나타내며, 진할수록 lift가 높음화살표도 그릴 수 있음 (from lhs to 곤)

Page 67: 메타데이터 - KOCWelearning.kocw.net/KOCW/document/2016/chungbuk/chowanseop/12.pdf · 개요 •R언어 – 데이터분석용으로특화된프로그래밍언어 – Arrays 혹은Matrix에대한연산들의모임

4. Sequential Patterns

• 순차패턴

– 순서대로 일어난 데이터를 분석하여 빈도수가 높은 순차패턴을 찾아 내는 마이닝 기법

– 순차패턴 알고리즘에서는 사용자가 정의한 최소 지지도이상의 순차패턴인 frequent sequences를 찾음

2016-09-30 Wan-Sup Cho ([email protected]) 67

Page 68: 메타데이터 - KOCWelearning.kocw.net/KOCW/document/2016/chungbuk/chowanseop/12.pdf · 개요 •R언어 – 데이터분석용으로특화된프로그래밍언어 – Arrays 혹은Matrix에대한연산들의모임

4. Sequential Patterns

2016-09-30 Wan-Sup Cho ([email protected]) 68

Support(<2,3>) = 0.6 //전체 고객중 (5명) 2와 3을 동시에 구매한 고객(3명)의 비율Support(<3>,<5>) = 0.8 //전체 고객중 3을 구매한 이후에 5를 구매한 비율 = 4/5

0.8

고객명 구매시간 구매한 상품들

Page 69: 메타데이터 - KOCWelearning.kocw.net/KOCW/document/2016/chungbuk/chowanseop/12.pdf · 개요 •R언어 – 데이터분석용으로특화된프로그래밍언어 – Arrays 혹은Matrix에대한연산들의모임

4. Sequential Patterns

2016-09-30 Wan-Sup Cho ([email protected]) 69

items sequenceID eventID SIZE1 {C,D} 1 10 22 {A,B,C} 1 15 33 {A,B,F} 1 20 34 {A,C,D,F} 1 25 45 {A,B,F} 2 15 36 {E} 2 20 17 {A,B,F} 3 10 38 {D,G,H} 4 10 39 {B,F} 4 20 210 {A,G,H} 4 25 3

Dataset zaki

> library(arulesSequences)> data(zaki)> as(zaki,"data.frame")> s1<-cspade(zaki, parameter=list(support=0.4), control=list(verbose=TRUE))> summary(s1)> as(s1, "data.frame")

Result (next page)

순차번호 구매상품 고객id 시간 구매상품수

Page 70: 메타데이터 - KOCWelearning.kocw.net/KOCW/document/2016/chungbuk/chowanseop/12.pdf · 개요 •R언어 – 데이터분석용으로특화된프로그래밍언어 – Arrays 혹은Matrix에대한연산들의모임

4. Sequential Patterns

2016-09-30 Wan-Sup Cho ([email protected]) 70

sequence support

1 <{A}> 1.00

2 <{B}> 1.00

3 <{D}> 0.50

4 <{F}> 1.00

5 <{A,F}> 0.75

6 <{B,F}> 1.00

7 <{D},{F}> 0.50

8 <{D},{B,F}> 0.50

9 <{A,B,F}> 0.75

10 <{A,B}> 0.75

11 <{D},{B}> 0.50

12 <{B},{A}> 0.50

13 <{D},{A}> 0.50

14 <{F},{A}> 0.50

15 <{D},{F},{A}> 0.50

16 <{B,F},{A}> 0.50

17 <{D},{B,F},{A}> 0.50

18 <{D},{B},{A}> 0.50

items sequenceID eventID SIZE

1 {C,D} 1 10 2

2 {A,B,C} 1 15 3

3 {A,B,F} 1 20 3

4 {A,C,D,F} 1 25 4

5 {A,B,F} 2 15 3

6 {E} 2 20 1

7 {A,B,F} 3 10 3

8 {D,G,H} 4 10 3

9 {B,F} 4 20 2

10 {A,G,H} 4 25 3

모든 고객이 A 를 구매함

75% 고객이 A와 F를 동시구매

50% 고객이 D 구매 후 F 구매

50% 고객이 D 구매 후 B, F 구매

50% 고객이 D => B => A 순서로구매

참고) https://en.wikibooks.org/wiki/Data_Mining_Algorithms_In_R/Sequence_Mining/SPADE

Page 71: 메타데이터 - KOCWelearning.kocw.net/KOCW/document/2016/chungbuk/chowanseop/12.pdf · 개요 •R언어 – 데이터분석용으로특화된프로그래밍언어 – Arrays 혹은Matrix에대한연산들의모임

5. Time Series Analysis and Mining

• AirPassengers 데이터셋

2016-09-30 Wan-Sup Cho ([email protected]) 71

> AirPassengersJan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec

1949 112 118 132 129 121 135 148 148 136 119 104 1181950 115 126 141 135 125 149 170 170 158 133 114 1401951 145 150 178 163 172 178 199 199 184 162 146 1661952 171 180 193 181 183 218 230 242 209 191 172 1941953 196 196 236 235 229 243 264 272 237 211 180 2011954 204 188 235 227 234 264 302 293 259 229 203 2291955 242 233 267 269 270 315 364 347 312 274 237 2781956 284 277 317 313 318 374 413 405 355 306 271 3061957 315 301 356 348 355 422 465 467 404 347 305 3361958 340 318 362 348 363 435 491 505 404 359 310 3371959 360 342 406 396 420 472 548 559 463 407 362 4051960 417 391 419 461 472 535 622 606 508 461 390 432

Page 72: 메타데이터 - KOCWelearning.kocw.net/KOCW/document/2016/chungbuk/chowanseop/12.pdf · 개요 •R언어 – 데이터분석용으로특화된프로그래밍언어 – Arrays 혹은Matrix에대한연산들의모임

5. Time Series Analysis and Mining

2016-09-30 Wan-Sup Cho ([email protected]) 72

> plot(AirPassengers)

Page 73: 메타데이터 - KOCWelearning.kocw.net/KOCW/document/2016/chungbuk/chowanseop/12.pdf · 개요 •R언어 – 데이터분석용으로특화된프로그래밍언어 – Arrays 혹은Matrix에대한연산들의모임

5. Time Series Analysis and Mining

2016-09-30 Wan-Sup Cho ([email protected]) 73

> fore<-predict(fit, n.ahead=24)> U<-fore$pred + 2*fore$se> L<-fore$pred - 2*fore$se> ts.plot(AirPassengers, fore$fred, U, L, col=c(1, 2, 4, 4), lty=c(1, 1, 2, 2))> legend("topleft",+ c("Actual", "Forecast", "Error Bounds (95% Confidence)"),+ col=c(1,2,4), lty=c(1,1,2))