SlideShare una empresa de Scribd logo
1 de 6
MapReduce 샘플 코드 및 실행 방법 정리
                           (Bioinformatics lab 대상 2차 세미나)



                                                              작성자 : 송주영(bt22dr@gmail.com)




    1. K-mer Counting
- K-mer
길이가 k인 염기서열 내의 연속된 염기
염기서열        ACGTACGTACGTA

K-mer (length = 6)   ACGTAC
                      CGTACG
                       GTACGT
                        TACGTA
                         ACGTAC
                          CGTACG
                           GTACGT
                            TACGTA


- 실행 방법
Usage: KmerCounting <in><out><k-mer length>


- 상세 실행 과정
[hadoop@cudatest hadoop]$ cd $HADOOP_HOME
[hadoop@cudatest hadoop]$ bin/hadoop dfs -ls Bio/input
Found 1 items
-rw-r--r-- 1 hadoop supergroup 33 2012-07-10 11:27 /user/hadoop/Bio/input/kmer_counting.txt
[hadoop@cudatest hadoop]$
[hadoop@cudatest hadoop]$ bin/hadoop dfs -cat Bio/input/kmer_counting.txt
ATGAACCTTA
GAACAACTTA
TTTAGGCAAC
[hadoop@cudatest hadoop]$ bin/hadoop jar example.jar KmerCounting Bio/input Bio/output 3
****hdfs://cudatest:9000/user/hadoop/Bio/input
12/07/10 18:08:55 INFO input.FileInputFormat: Total input paths to process : 1
12/07/10 18:08:55 INFO util.NativeCodeLoader: Loaded the native-hadoop library
12/07/10 18:08:55 WARN snappy.LoadSnappy: Snappy native library not loaded
12/07/10 18:08:55 INFO mapred.JobClient: Running job: job_201207051452_0021
12/07/10 18:08:56 INFO mapred.JobClient: map 0% reduce 0%
12/07/10 18:09:09 INFO mapred.JobClient: map 100% reduce 0%
12/07/10 18:09:21 INFO mapred.JobClient: map 100% reduce 100%
12/07/10 18:09:27 INFO mapred.JobClient: Job complete: job_201207051452_0021
12/07/10 18:09:27 INFO mapred.JobClient: Counters: 29
… 중략 …
12/07/10 18:09:27 INFO mapred.JobClient: Combine output records=0
12/07/10 18:09:27 INFO mapred.JobClient: Physical memory (bytes) snapshot=275869696
12/07/10 18:09:27 INFO mapred.JobClient: Reduce output records=16
12/07/10 18:09:27 INFO mapred.JobClient: Virtual memory (bytes) snapshot=1186914304
12/07/10 18:09:27 INFO mapred.JobClient: Map output records=24
[hadoop@cudatest hadoop]$ bin/hadoop dfs -cat Bio/output/part-r-00000
AAC 4
ACA 1
ACC 1
ACT 1
AGG 1
ATG 1
CAA 2
CCT 1
CTT 2
GAA 2
GCA 1
GGC 1
TAG 1
TGA 1
TTA 3
TTT 1



- 비교 및 확인




<출처 : http://schatzlab.cshl.edu/presentations/2010-03-15.XGen-Scalable%20Solutions.pdf>



※ 위 원문 자료 오류: [CTT : 1]과 [GAA : 1]을 [CTT : 2]과 [GAA : 2]로 수정해야 함.
K-means Clustering

주어진 데이터를 k개의 클러스터로 묶는 알고리즘. 주어진 데이터를 가장 거리가 가까운 것들끼
리 k개의 클러스터로 군집하여 모든 데이터와 해당 클러스터의 centroid와의 거리합이 최소가 되
도록 반복연산을 수행한다.



- 실행 방법
Usage: KmeansClustering <in><out><k: # of cluster><x: maximum iteration>


- 상세 실행 과정
1. 입력 데이터 생성
[hadoop@cudatest hadoop]$ R
>library(rhdfs)
>library(rmr)
>x <- rbind(matrix(rnorm(10, sd = 0.3), ncol = 2),
+             matrix(rnorm(10, mean = 1, sd = 0.3), ncol = 2))
>to.dfs(x, "/user/hadoop/Kmeans/input/kmeans_data_10.txt", format="text")

[1] "/user/hadoop/Kmeans/input/kmeans_test.txt"
>plot(x, col = cl$cluster)


2. Clustering 수행
[hadoop@cudatest hadoop]$ bin/hadoop dfs -ls Kmeans

Found 1 items
drwxr-xr-x  - hadoop supergroup        0 2012-07-13 17:42 /user/hadoop/Kmeans/input
[hadoop@cudatest hadoop]$ bin/hadoop dfs -ls Kmeans/input

Found 1 items
-rw-r--r-- 1…2012-07-13 17:41 /user/hadoop/Kmeans/input/kmeans_data_10.txt
[hadoop@cudatest hadoop]$ bin/hadoop jar BQR.jar com.skcc.services.BQR.KmeansClustering
Kmeans/input Kmeans/output 2 5

12/07/13 17:55:29 WARN mapred.JobClient: Use GenericOptionsParser for parsing the arguments. Applications
should implement Tool for the same.
****hdfs://cudatest:9000/user/hadoop/Kmeans/input
12/07/13 17:55:29 INFO input.FileInputFormat: Total input paths to process : 1
12/07/13 17:55:29 INFO util.NativeCodeLoader: Loaded the native-hadoop library
12/07/13 17:55:29 WARN snappy.LoadSnappy: Snappy native library not loaded
12/07/13 17:55:29 INFO mapred.JobClient: Running job: job_201207131700_0019
12/07/13 17:55:30 INFO mapred.JobClient: map 0% reduce 0%

…생략…

[hadoop@cudatest hadoop]$ bin/hadoop dfs -cat Kmeans/output/5/part-r-00000

0                -0.220571493559915 0.0174640983069702 0.191775203854135 -0.0324478456055529
0.30730078757325 -0.446549547688165 0.12718989634021 0.133229105022227
1       0.635665082648627 0.466306965120643 1.24647562794383 1.08065598756178 0.841377542119699
1.04601249480335     1.28393866595644   1.6448881770345    0.987943522251124  0.619578600258074
0.57360383756511 1.38138384087598
- 소스코드 설명
코드는 총 4개의 Mapper, Reducer 클래스로 구성되어 있으며,
Clustering 과정은 크게 3가지 MapReduce 작업으로 이루어진다.
       generateSeed( ) : 최초 seed로 사용할 centroid를 생성
       kmeansIter( ) : centroid를 갱신하며 clustering. 반복 수행함
       resultKmeans( ) : 최종 결과 생성


전체 구조도




Key-Value 설계

    map              : (k1, v1) -> list(k2, v2)
    reduce           : (k2, list(v2)) -> list(v3)

GenSeedMapper
    -    입력 : [ 키: 라인 offset,    값: <x y> ]
    -    출력 : [ 키: center ID,    값: <x y>]
KmeansReducer
    -    입력 : [ 키: center ID,    값: list(<x y>) ]
    -    출력 : [ 키: center ID,    값: 해당 클러스터의 mean값 <x y>]


KmeansMapper
    -    Setup: [ 이전 단계 Reducer의 결과 읽기 ]
    -    입력 : [ 키: 라인 offset,                       값: <x y> ]
    -    출력 : [ 키: <x y>에 제일 가까운 center ID,         값: x y ]


ResultReducer
-   입력 : [ 키: center ID,          값: list(<x y>) ]
  -   출력 : [ 키: center ID,          값: 해당 ID에 포함된 <x y> list ]


- 입/출력
                입력                                                   출력
-0.220571493559915 0.0174640983069702      0              -0.220571493559915       0.0174640983069702
0.191775203854135 -0.0324478456055529      0.191775203854135 -0.0324478456055529 0.30730078757325
0.30730078757325 -0.446549547688165        -0.446549547688165 0.12718989634021 0.133229105022227
0.12718989634021 0.133229105022227         1                  0.635665082648627     0.466306965120643
0.635665082648627 0.466306965120643        1.24647562794383    1.08065598756178     0.841377542119699
1.24647562794383 1.08065598756178          1.04601249480335     1.28393866595644      1.6448881770345
0.841377542119699 1.04601249480335         0.987943522251124 0.619578600258074 0.57360383756511
1.28393866595644 1.6448881770345           1.38138384087598
0.987943522251124 0.619578600258074
0.57360383756511 1.38138384087598



- 비교 및 확인

Más contenido relacionado

La actualidad más candente

R 스터디 세번째
R 스터디 세번째R 스터디 세번째
R 스터디 세번째Jaeseok Park
 
[2009 CodeEngn Conference 03] hkpco - DEFCON CTF 2009 Binary Leetness 100-500...
[2009 CodeEngn Conference 03] hkpco - DEFCON CTF 2009 Binary Leetness 100-500...[2009 CodeEngn Conference 03] hkpco - DEFCON CTF 2009 Binary Leetness 100-500...
[2009 CodeEngn Conference 03] hkpco - DEFCON CTF 2009 Binary Leetness 100-500...GangSeok Lee
 
Python의 계산성능 향상을 위해 Fortran, C, CUDA-C, OpenCL-C 코드들과 연동하기
Python의 계산성능 향상을 위해 Fortran, C, CUDA-C, OpenCL-C 코드들과 연동하기Python의 계산성능 향상을 위해 Fortran, C, CUDA-C, OpenCL-C 코드들과 연동하기
Python의 계산성능 향상을 위해 Fortran, C, CUDA-C, OpenCL-C 코드들과 연동하기Ki-Hwan Kim
 
practice2
practice2practice2
practice2yosm
 
Python machine learning Ch.4
Python machine learning Ch.4Python machine learning Ch.4
Python machine learning Ch.4PartPrime
 
ffmpeg optimization using CUDA
ffmpeg optimization using CUDAffmpeg optimization using CUDA
ffmpeg optimization using CUDAyyooooon
 
하둡 맵리듀스 훑어보기
하둡 맵리듀스 훑어보기하둡 맵리듀스 훑어보기
하둡 맵리듀스 훑어보기beom kyun choi
 
R 스터디 첫번째
R 스터디 첫번째R 스터디 첫번째
R 스터디 첫번째Jaeseok Park
 
Sicp 2.2 계층 구조 데이터와 닫힘 성질
Sicp 2.2 계층 구조 데이터와 닫힘 성질Sicp 2.2 계층 구조 데이터와 닫힘 성질
Sicp 2.2 계층 구조 데이터와 닫힘 성질aceigy6322
 
R 스터디 두번째
R 스터디 두번째R 스터디 두번째
R 스터디 두번째Jaeseok Park
 
Centroid Decomposition - Sogang ICPC Team, 2019
Centroid Decomposition - Sogang ICPC Team, 2019Centroid Decomposition - Sogang ICPC Team, 2019
Centroid Decomposition - Sogang ICPC Team, 2019Suhyun Park
 
Persistent Segment Tree - Sogang ICPC Team, 2019
Persistent Segment Tree - Sogang ICPC Team, 2019Persistent Segment Tree - Sogang ICPC Team, 2019
Persistent Segment Tree - Sogang ICPC Team, 2019Suhyun Park
 
ALS WS에 대한 이해 자료
ALS WS에 대한 이해 자료ALS WS에 대한 이해 자료
ALS WS에 대한 이해 자료beom kyun choi
 
Adv sys prog_20123186_report1
Adv sys prog_20123186_report1Adv sys prog_20123186_report1
Adv sys prog_20123186_report1준석 김
 
[Algorithm] Recursive(재귀)
[Algorithm] Recursive(재귀)[Algorithm] Recursive(재귀)
[Algorithm] Recursive(재귀)Bill Kim
 
윤석준 2015 cuda_contest
윤석준 2015 cuda_contest윤석준 2015 cuda_contest
윤석준 2015 cuda_contestSeok-joon Yun
 
Fast Fourier Transform - Sogang ICPC Team, 2019
Fast Fourier Transform - Sogang ICPC Team, 2019Fast Fourier Transform - Sogang ICPC Team, 2019
Fast Fourier Transform - Sogang ICPC Team, 2019Suhyun Park
 
알고리즘과 자료구조
알고리즘과 자료구조알고리즘과 자료구조
알고리즘과 자료구조영기 김
 

La actualidad más candente (20)

R 스터디 세번째
R 스터디 세번째R 스터디 세번째
R 스터디 세번째
 
[2009 CodeEngn Conference 03] hkpco - DEFCON CTF 2009 Binary Leetness 100-500...
[2009 CodeEngn Conference 03] hkpco - DEFCON CTF 2009 Binary Leetness 100-500...[2009 CodeEngn Conference 03] hkpco - DEFCON CTF 2009 Binary Leetness 100-500...
[2009 CodeEngn Conference 03] hkpco - DEFCON CTF 2009 Binary Leetness 100-500...
 
Python의 계산성능 향상을 위해 Fortran, C, CUDA-C, OpenCL-C 코드들과 연동하기
Python의 계산성능 향상을 위해 Fortran, C, CUDA-C, OpenCL-C 코드들과 연동하기Python의 계산성능 향상을 위해 Fortran, C, CUDA-C, OpenCL-C 코드들과 연동하기
Python의 계산성능 향상을 위해 Fortran, C, CUDA-C, OpenCL-C 코드들과 연동하기
 
practice2
practice2practice2
practice2
 
Python machine learning Ch.4
Python machine learning Ch.4Python machine learning Ch.4
Python machine learning Ch.4
 
ffmpeg optimization using CUDA
ffmpeg optimization using CUDAffmpeg optimization using CUDA
ffmpeg optimization using CUDA
 
하둡 맵리듀스 훑어보기
하둡 맵리듀스 훑어보기하둡 맵리듀스 훑어보기
하둡 맵리듀스 훑어보기
 
R 스터디 첫번째
R 스터디 첫번째R 스터디 첫번째
R 스터디 첫번째
 
Sicp 2.2 계층 구조 데이터와 닫힘 성질
Sicp 2.2 계층 구조 데이터와 닫힘 성질Sicp 2.2 계층 구조 데이터와 닫힘 성질
Sicp 2.2 계층 구조 데이터와 닫힘 성질
 
R 스터디 두번째
R 스터디 두번째R 스터디 두번째
R 스터디 두번째
 
Centroid Decomposition - Sogang ICPC Team, 2019
Centroid Decomposition - Sogang ICPC Team, 2019Centroid Decomposition - Sogang ICPC Team, 2019
Centroid Decomposition - Sogang ICPC Team, 2019
 
Persistent Segment Tree - Sogang ICPC Team, 2019
Persistent Segment Tree - Sogang ICPC Team, 2019Persistent Segment Tree - Sogang ICPC Team, 2019
Persistent Segment Tree - Sogang ICPC Team, 2019
 
R intro
R introR intro
R intro
 
ALS WS에 대한 이해 자료
ALS WS에 대한 이해 자료ALS WS에 대한 이해 자료
ALS WS에 대한 이해 자료
 
Adv sys prog_20123186_report1
Adv sys prog_20123186_report1Adv sys prog_20123186_report1
Adv sys prog_20123186_report1
 
[Algorithm] Recursive(재귀)
[Algorithm] Recursive(재귀)[Algorithm] Recursive(재귀)
[Algorithm] Recursive(재귀)
 
윤석준 2015 cuda_contest
윤석준 2015 cuda_contest윤석준 2015 cuda_contest
윤석준 2015 cuda_contest
 
R_datamining
R_dataminingR_datamining
R_datamining
 
Fast Fourier Transform - Sogang ICPC Team, 2019
Fast Fourier Transform - Sogang ICPC Team, 2019Fast Fourier Transform - Sogang ICPC Team, 2019
Fast Fourier Transform - Sogang ICPC Team, 2019
 
알고리즘과 자료구조
알고리즘과 자료구조알고리즘과 자료구조
알고리즘과 자료구조
 

Destacado

Scriptura Praeteriti
Scriptura PraeteritiScriptura Praeteriti
Scriptura Praeteritijuudiith01
 
Regression &amp; Classification
Regression &amp; ClassificationRegression &amp; Classification
Regression &amp; Classification주영 송
 
E safety in the school management system
E safety  in the school management systemE safety  in the school management system
E safety in the school management systemEASO Politeknikoa
 
Casas madera criterios_medioambientales
Casas madera criterios_medioambientalesCasas madera criterios_medioambientales
Casas madera criterios_medioambientalesEASO Politeknikoa
 
소셜미디어 사서직 취업동향
소셜미디어 사서직 취업동향소셜미디어 사서직 취업동향
소셜미디어 사서직 취업동향Gil Su Jang
 
eSafety: pasa-hitz seguruen erabilpena
eSafety:  pasa-hitz seguruen erabilpenaeSafety:  pasa-hitz seguruen erabilpena
eSafety: pasa-hitz seguruen erabilpenaEASO Politeknikoa
 
10 logical clocks
10 logical clocks10 logical clocks
10 logical clocksThuy Hu
 
Dig comporg arantzabela_ikastola
Dig comporg arantzabela_ikastolaDig comporg arantzabela_ikastola
Dig comporg arantzabela_ikastolaEASO Politeknikoa
 
Cloud burst tutorial
Cloud burst tutorialCloud burst tutorial
Cloud burst tutorial주영 송
 
Scriptura Praeteriti
Scriptura PraeteritiScriptura Praeteriti
Scriptura Praeteritijuudiith01
 
Nasıl Fikirci Olunur
Nasıl Fikirci OlunurNasıl Fikirci Olunur
Nasıl Fikirci OlunurFikirMarketim
 
Prestakuntza eSafety irakasleen prestakuntza plana 2014 2015
Prestakuntza eSafety irakasleen prestakuntza plana 2014 2015 Prestakuntza eSafety irakasleen prestakuntza plana 2014 2015
Prestakuntza eSafety irakasleen prestakuntza plana 2014 2015 EASO Politeknikoa
 
Kuluçka Prensibiyle Düşünme Tekniği
Kuluçka Prensibiyle Düşünme TekniğiKuluçka Prensibiyle Düşünme Tekniği
Kuluçka Prensibiyle Düşünme TekniğiFikirMarketim
 
Slideshare powerpoint
Slideshare powerpointSlideshare powerpoint
Slideshare powerpointJack Matthews
 

Destacado (20)

Scriptura Praeteriti
Scriptura PraeteritiScriptura Praeteriti
Scriptura Praeteriti
 
Regression &amp; Classification
Regression &amp; ClassificationRegression &amp; Classification
Regression &amp; Classification
 
E safety in the school management system
E safety  in the school management systemE safety  in the school management system
E safety in the school management system
 
Casas madera criterios_medioambientales
Casas madera criterios_medioambientalesCasas madera criterios_medioambientales
Casas madera criterios_medioambientales
 
Beerlegend.by
Beerlegend.byBeerlegend.by
Beerlegend.by
 
Mobiliario ecodisenado
Mobiliario ecodisenadoMobiliario ecodisenado
Mobiliario ecodisenado
 
Concurso diseno muebles
Concurso diseno mueblesConcurso diseno muebles
Concurso diseno muebles
 
Dig comporg TKNIKA
Dig comporg TKNIKADig comporg TKNIKA
Dig comporg TKNIKA
 
소셜미디어 사서직 취업동향
소셜미디어 사서직 취업동향소셜미디어 사서직 취업동향
소셜미디어 사서직 취업동향
 
eSafety: pasa-hitz seguruen erabilpena
eSafety:  pasa-hitz seguruen erabilpenaeSafety:  pasa-hitz seguruen erabilpena
eSafety: pasa-hitz seguruen erabilpena
 
10 logical clocks
10 logical clocks10 logical clocks
10 logical clocks
 
Dig comporg arantzabela_ikastola
Dig comporg arantzabela_ikastolaDig comporg arantzabela_ikastola
Dig comporg arantzabela_ikastola
 
Icbme 2011
Icbme 2011Icbme 2011
Icbme 2011
 
Cloud burst tutorial
Cloud burst tutorialCloud burst tutorial
Cloud burst tutorial
 
Scriptura Praeteriti
Scriptura PraeteritiScriptura Praeteriti
Scriptura Praeteriti
 
museum
museummuseum
museum
 
Nasıl Fikirci Olunur
Nasıl Fikirci OlunurNasıl Fikirci Olunur
Nasıl Fikirci Olunur
 
Prestakuntza eSafety irakasleen prestakuntza plana 2014 2015
Prestakuntza eSafety irakasleen prestakuntza plana 2014 2015 Prestakuntza eSafety irakasleen prestakuntza plana 2014 2015
Prestakuntza eSafety irakasleen prestakuntza plana 2014 2015
 
Kuluçka Prensibiyle Düşünme Tekniği
Kuluçka Prensibiyle Düşünme TekniğiKuluçka Prensibiyle Düşünme Tekniği
Kuluçka Prensibiyle Düşünme Tekniği
 
Slideshare powerpoint
Slideshare powerpointSlideshare powerpoint
Slideshare powerpoint
 

Similar a MapReduce 실행 샘플 (K-mer Counting, K-means Clustering)

20150212 c++11 features used in crow
20150212 c++11 features used in crow20150212 c++11 features used in crow
20150212 c++11 features used in crowJaeseung Ha
 
Deview 2019 눈발자국
Deview 2019 눈발자국Deview 2019 눈발자국
Deview 2019 눈발자국hanbeom Park
 
[NDC2015] C++11 고급 기능 - Crow에 사용된 기법 중심으로
[NDC2015] C++11 고급 기능 - Crow에 사용된 기법 중심으로[NDC2015] C++11 고급 기능 - Crow에 사용된 기법 중심으로
[NDC2015] C++11 고급 기능 - Crow에 사용된 기법 중심으로Jaeseung Ha
 
House pricing prediction in R(Regression Project)
House pricing prediction in R(Regression Project)House pricing prediction in R(Regression Project)
House pricing prediction in R(Regression Project)Adonis Han
 
Prometheus Project Journey
Prometheus Project JourneyPrometheus Project Journey
Prometheus Project JourneyJinwoong Kim
 
3ds maxscript 튜토리얼_20151206_서진택
3ds maxscript 튜토리얼_20151206_서진택3ds maxscript 튜토리얼_20151206_서진택
3ds maxscript 튜토리얼_20151206_서진택JinTaek Seo
 
R 프로그램의 이해와 활용 v1.1
R 프로그램의 이해와 활용 v1.1R 프로그램의 이해와 활용 v1.1
R 프로그램의 이해와 활용 v1.1happychallenge
 
[devil's camp] - 알고리즘 대회와 STL (박인서)
[devil's camp] - 알고리즘 대회와 STL (박인서)[devil's camp] - 알고리즘 대회와 STL (박인서)
[devil's camp] - 알고리즘 대회와 STL (박인서)NAVER D2
 
프로그래밍 대회: C++11 이야기
프로그래밍 대회: C++11 이야기프로그래밍 대회: C++11 이야기
프로그래밍 대회: C++11 이야기Jongwook Choi
 
C++ 프로젝트에 단위 테스트 도입하기
C++ 프로젝트에 단위 테스트 도입하기C++ 프로젝트에 단위 테스트 도입하기
C++ 프로젝트에 단위 테스트 도입하기OnGameServer
 
불어오는 변화의 바람, From c++98 to c++11, 14
불어오는 변화의 바람, From c++98 to c++11, 14 불어오는 변화의 바람, From c++98 to c++11, 14
불어오는 변화의 바람, From c++98 to c++11, 14 명신 김
 
데이타베이스 기본튜닝
데이타베이스 기본튜닝 데이타베이스 기본튜닝
데이타베이스 기본튜닝 Jinuk Bhak
 
Reproducible research(2)
Reproducible research(2)Reproducible research(2)
Reproducible research(2)건웅 문
 
DEVIEW-FULL-감독판.pptx
DEVIEW-FULL-감독판.pptxDEVIEW-FULL-감독판.pptx
DEVIEW-FULL-감독판.pptxhanbeom Park
 
android stuff1
android stuff1android stuff1
android stuff1Jin Jiu
 
2017 Software Edu Fest - 생활속데이터 이야기 @ 세상을 변화시키는 소프트웨어 기술
2017 Software Edu Fest - 생활속데이터 이야기 @ 세상을 변화시키는 소프트웨어 기술2017 Software Edu Fest - 생활속데이터 이야기 @ 세상을 변화시키는 소프트웨어 기술
2017 Software Edu Fest - 생활속데이터 이야기 @ 세상을 변화시키는 소프트웨어 기술Kyuho Kim
 
헤테로지니어스 컴퓨팅 : CPU 에서 GPU 로 옮겨가기
헤테로지니어스 컴퓨팅 :  CPU 에서 GPU 로 옮겨가기헤테로지니어스 컴퓨팅 :  CPU 에서 GPU 로 옮겨가기
헤테로지니어스 컴퓨팅 : CPU 에서 GPU 로 옮겨가기zupet
 

Similar a MapReduce 실행 샘플 (K-mer Counting, K-means Clustering) (20)

20150212 c++11 features used in crow
20150212 c++11 features used in crow20150212 c++11 features used in crow
20150212 c++11 features used in crow
 
Deview 2019 눈발자국
Deview 2019 눈발자국Deview 2019 눈발자국
Deview 2019 눈발자국
 
[NDC2015] C++11 고급 기능 - Crow에 사용된 기법 중심으로
[NDC2015] C++11 고급 기능 - Crow에 사용된 기법 중심으로[NDC2015] C++11 고급 기능 - Crow에 사용된 기법 중심으로
[NDC2015] C++11 고급 기능 - Crow에 사용된 기법 중심으로
 
House pricing prediction in R(Regression Project)
House pricing prediction in R(Regression Project)House pricing prediction in R(Regression Project)
House pricing prediction in R(Regression Project)
 
Prometheus Project Journey
Prometheus Project JourneyPrometheus Project Journey
Prometheus Project Journey
 
3ds maxscript 튜토리얼_20151206_서진택
3ds maxscript 튜토리얼_20151206_서진택3ds maxscript 튜토리얼_20151206_서진택
3ds maxscript 튜토리얼_20151206_서진택
 
R 프로그램의 이해와 활용 v1.1
R 프로그램의 이해와 활용 v1.1R 프로그램의 이해와 활용 v1.1
R 프로그램의 이해와 활용 v1.1
 
[devil's camp] - 알고리즘 대회와 STL (박인서)
[devil's camp] - 알고리즘 대회와 STL (박인서)[devil's camp] - 알고리즘 대회와 STL (박인서)
[devil's camp] - 알고리즘 대회와 STL (박인서)
 
프로그래밍 대회: C++11 이야기
프로그래밍 대회: C++11 이야기프로그래밍 대회: C++11 이야기
프로그래밍 대회: C++11 이야기
 
C++ 프로젝트에 단위 테스트 도입하기
C++ 프로젝트에 단위 테스트 도입하기C++ 프로젝트에 단위 테스트 도입하기
C++ 프로젝트에 단위 테스트 도입하기
 
불어오는 변화의 바람, From c++98 to c++11, 14
불어오는 변화의 바람, From c++98 to c++11, 14 불어오는 변화의 바람, From c++98 to c++11, 14
불어오는 변화의 바람, From c++98 to c++11, 14
 
Tcpdump
TcpdumpTcpdump
Tcpdump
 
데이타베이스 기본튜닝
데이타베이스 기본튜닝 데이타베이스 기본튜닝
데이타베이스 기본튜닝
 
Reproducible research(2)
Reproducible research(2)Reproducible research(2)
Reproducible research(2)
 
DEVIEW-FULL-감독판.pptx
DEVIEW-FULL-감독판.pptxDEVIEW-FULL-감독판.pptx
DEVIEW-FULL-감독판.pptx
 
android stuff1
android stuff1android stuff1
android stuff1
 
Rx java intro
Rx java introRx java intro
Rx java intro
 
2017 Software Edu Fest - 생활속데이터 이야기 @ 세상을 변화시키는 소프트웨어 기술
2017 Software Edu Fest - 생활속데이터 이야기 @ 세상을 변화시키는 소프트웨어 기술2017 Software Edu Fest - 생활속데이터 이야기 @ 세상을 변화시키는 소프트웨어 기술
2017 Software Edu Fest - 생활속데이터 이야기 @ 세상을 변화시키는 소프트웨어 기술
 
헤테로지니어스 컴퓨팅 : CPU 에서 GPU 로 옮겨가기
헤테로지니어스 컴퓨팅 :  CPU 에서 GPU 로 옮겨가기헤테로지니어스 컴퓨팅 :  CPU 에서 GPU 로 옮겨가기
헤테로지니어스 컴퓨팅 : CPU 에서 GPU 로 옮겨가기
 
[week6]R_Wrangling
[week6]R_Wrangling[week6]R_Wrangling
[week6]R_Wrangling
 

Más de 주영 송

5일차.map reduce 활용
5일차.map reduce 활용5일차.map reduce 활용
5일차.map reduce 활용주영 송
 
SNA & R (20121011)
SNA & R (20121011)SNA & R (20121011)
SNA & R (20121011)주영 송
 
Recommendation system 소개 (1)
Recommendation system 소개 (1)Recommendation system 소개 (1)
Recommendation system 소개 (1)주영 송
 
Cloud burst 소개
Cloud burst 소개Cloud burst 소개
Cloud burst 소개주영 송
 
Mongo db 활용 가이드 ch7
Mongo db 활용 가이드 ch7Mongo db 활용 가이드 ch7
Mongo db 활용 가이드 ch7주영 송
 

Más de 주영 송 (8)

Giraph
GiraphGiraph
Giraph
 
Mahout
MahoutMahout
Mahout
 
5일차.map reduce 활용
5일차.map reduce 활용5일차.map reduce 활용
5일차.map reduce 활용
 
SNA & R (20121011)
SNA & R (20121011)SNA & R (20121011)
SNA & R (20121011)
 
Recommendation system 소개 (1)
Recommendation system 소개 (1)Recommendation system 소개 (1)
Recommendation system 소개 (1)
 
Cloud burst 소개
Cloud burst 소개Cloud burst 소개
Cloud burst 소개
 
Cuda intro
Cuda introCuda intro
Cuda intro
 
Mongo db 활용 가이드 ch7
Mongo db 활용 가이드 ch7Mongo db 활용 가이드 ch7
Mongo db 활용 가이드 ch7
 

MapReduce 실행 샘플 (K-mer Counting, K-means Clustering)

  • 1. MapReduce 샘플 코드 및 실행 방법 정리 (Bioinformatics lab 대상 2차 세미나) 작성자 : 송주영(bt22dr@gmail.com) 1. K-mer Counting - K-mer 길이가 k인 염기서열 내의 연속된 염기 염기서열 ACGTACGTACGTA K-mer (length = 6) ACGTAC CGTACG GTACGT TACGTA ACGTAC CGTACG GTACGT TACGTA - 실행 방법 Usage: KmerCounting <in><out><k-mer length> - 상세 실행 과정 [hadoop@cudatest hadoop]$ cd $HADOOP_HOME [hadoop@cudatest hadoop]$ bin/hadoop dfs -ls Bio/input Found 1 items -rw-r--r-- 1 hadoop supergroup 33 2012-07-10 11:27 /user/hadoop/Bio/input/kmer_counting.txt [hadoop@cudatest hadoop]$ [hadoop@cudatest hadoop]$ bin/hadoop dfs -cat Bio/input/kmer_counting.txt ATGAACCTTA GAACAACTTA TTTAGGCAAC [hadoop@cudatest hadoop]$ bin/hadoop jar example.jar KmerCounting Bio/input Bio/output 3 ****hdfs://cudatest:9000/user/hadoop/Bio/input 12/07/10 18:08:55 INFO input.FileInputFormat: Total input paths to process : 1 12/07/10 18:08:55 INFO util.NativeCodeLoader: Loaded the native-hadoop library 12/07/10 18:08:55 WARN snappy.LoadSnappy: Snappy native library not loaded 12/07/10 18:08:55 INFO mapred.JobClient: Running job: job_201207051452_0021 12/07/10 18:08:56 INFO mapred.JobClient: map 0% reduce 0% 12/07/10 18:09:09 INFO mapred.JobClient: map 100% reduce 0% 12/07/10 18:09:21 INFO mapred.JobClient: map 100% reduce 100% 12/07/10 18:09:27 INFO mapred.JobClient: Job complete: job_201207051452_0021 12/07/10 18:09:27 INFO mapred.JobClient: Counters: 29 … 중략 … 12/07/10 18:09:27 INFO mapred.JobClient: Combine output records=0 12/07/10 18:09:27 INFO mapred.JobClient: Physical memory (bytes) snapshot=275869696
  • 2. 12/07/10 18:09:27 INFO mapred.JobClient: Reduce output records=16 12/07/10 18:09:27 INFO mapred.JobClient: Virtual memory (bytes) snapshot=1186914304 12/07/10 18:09:27 INFO mapred.JobClient: Map output records=24 [hadoop@cudatest hadoop]$ bin/hadoop dfs -cat Bio/output/part-r-00000 AAC 4 ACA 1 ACC 1 ACT 1 AGG 1 ATG 1 CAA 2 CCT 1 CTT 2 GAA 2 GCA 1 GGC 1 TAG 1 TGA 1 TTA 3 TTT 1 - 비교 및 확인 <출처 : http://schatzlab.cshl.edu/presentations/2010-03-15.XGen-Scalable%20Solutions.pdf> ※ 위 원문 자료 오류: [CTT : 1]과 [GAA : 1]을 [CTT : 2]과 [GAA : 2]로 수정해야 함.
  • 3.
  • 4. K-means Clustering 주어진 데이터를 k개의 클러스터로 묶는 알고리즘. 주어진 데이터를 가장 거리가 가까운 것들끼 리 k개의 클러스터로 군집하여 모든 데이터와 해당 클러스터의 centroid와의 거리합이 최소가 되 도록 반복연산을 수행한다. - 실행 방법 Usage: KmeansClustering <in><out><k: # of cluster><x: maximum iteration> - 상세 실행 과정 1. 입력 데이터 생성 [hadoop@cudatest hadoop]$ R >library(rhdfs) >library(rmr) >x <- rbind(matrix(rnorm(10, sd = 0.3), ncol = 2), + matrix(rnorm(10, mean = 1, sd = 0.3), ncol = 2)) >to.dfs(x, "/user/hadoop/Kmeans/input/kmeans_data_10.txt", format="text") [1] "/user/hadoop/Kmeans/input/kmeans_test.txt" >plot(x, col = cl$cluster) 2. Clustering 수행 [hadoop@cudatest hadoop]$ bin/hadoop dfs -ls Kmeans Found 1 items drwxr-xr-x - hadoop supergroup 0 2012-07-13 17:42 /user/hadoop/Kmeans/input [hadoop@cudatest hadoop]$ bin/hadoop dfs -ls Kmeans/input Found 1 items -rw-r--r-- 1…2012-07-13 17:41 /user/hadoop/Kmeans/input/kmeans_data_10.txt [hadoop@cudatest hadoop]$ bin/hadoop jar BQR.jar com.skcc.services.BQR.KmeansClustering Kmeans/input Kmeans/output 2 5 12/07/13 17:55:29 WARN mapred.JobClient: Use GenericOptionsParser for parsing the arguments. Applications should implement Tool for the same. ****hdfs://cudatest:9000/user/hadoop/Kmeans/input 12/07/13 17:55:29 INFO input.FileInputFormat: Total input paths to process : 1 12/07/13 17:55:29 INFO util.NativeCodeLoader: Loaded the native-hadoop library 12/07/13 17:55:29 WARN snappy.LoadSnappy: Snappy native library not loaded 12/07/13 17:55:29 INFO mapred.JobClient: Running job: job_201207131700_0019 12/07/13 17:55:30 INFO mapred.JobClient: map 0% reduce 0% …생략… [hadoop@cudatest hadoop]$ bin/hadoop dfs -cat Kmeans/output/5/part-r-00000 0 -0.220571493559915 0.0174640983069702 0.191775203854135 -0.0324478456055529 0.30730078757325 -0.446549547688165 0.12718989634021 0.133229105022227 1 0.635665082648627 0.466306965120643 1.24647562794383 1.08065598756178 0.841377542119699 1.04601249480335 1.28393866595644 1.6448881770345 0.987943522251124 0.619578600258074 0.57360383756511 1.38138384087598
  • 5. - 소스코드 설명 코드는 총 4개의 Mapper, Reducer 클래스로 구성되어 있으며, Clustering 과정은 크게 3가지 MapReduce 작업으로 이루어진다.  generateSeed( ) : 최초 seed로 사용할 centroid를 생성  kmeansIter( ) : centroid를 갱신하며 clustering. 반복 수행함  resultKmeans( ) : 최종 결과 생성 전체 구조도 Key-Value 설계 map : (k1, v1) -> list(k2, v2) reduce : (k2, list(v2)) -> list(v3) GenSeedMapper - 입력 : [ 키: 라인 offset, 값: <x y> ] - 출력 : [ 키: center ID, 값: <x y>] KmeansReducer - 입력 : [ 키: center ID, 값: list(<x y>) ] - 출력 : [ 키: center ID, 값: 해당 클러스터의 mean값 <x y>] KmeansMapper - Setup: [ 이전 단계 Reducer의 결과 읽기 ] - 입력 : [ 키: 라인 offset, 값: <x y> ] - 출력 : [ 키: <x y>에 제일 가까운 center ID, 값: x y ] ResultReducer
  • 6. - 입력 : [ 키: center ID, 값: list(<x y>) ] - 출력 : [ 키: center ID, 값: 해당 ID에 포함된 <x y> list ] - 입/출력 입력 출력 -0.220571493559915 0.0174640983069702 0 -0.220571493559915 0.0174640983069702 0.191775203854135 -0.0324478456055529 0.191775203854135 -0.0324478456055529 0.30730078757325 0.30730078757325 -0.446549547688165 -0.446549547688165 0.12718989634021 0.133229105022227 0.12718989634021 0.133229105022227 1 0.635665082648627 0.466306965120643 0.635665082648627 0.466306965120643 1.24647562794383 1.08065598756178 0.841377542119699 1.24647562794383 1.08065598756178 1.04601249480335 1.28393866595644 1.6448881770345 0.841377542119699 1.04601249480335 0.987943522251124 0.619578600258074 0.57360383756511 1.28393866595644 1.6448881770345 1.38138384087598 0.987943522251124 0.619578600258074 0.57360383756511 1.38138384087598 - 비교 및 확인