SlideShare a Scribd company logo
1 of 55
Download to read offline
(node, vertex)
(edge, link)
0 1 0 0 0 0
0 0 1 0 0 0
0 0 0 0 1 0
0 1 0 0 0 0
0 0 0 1 0 1
0 0 0 0 0 0
A B
B C
C E
D B
E D
E F
#
whiskies <- data.table::fread("http://
outreach.mathstat.strath.ac.uk/outreach/nessie/datasets/
whiskies.txt", header = TRUE)
#
cor.mat <- whiskies %>%
select(Body, Sweetness, Smoky, Medicinal, Tobacco, Honey,
Spicy, Winey, Nutty, Malty, Fruity, Floral) %>%
t() %>%
cor()
#
colnames(cor.mat) <- whiskies$Distillery
rownames(cor.mat) <- whiskies$Distillery
#
cor.mat[upper.tri(cor.mat, diag = TRUE)] <- NA
cor.mat[1:5, 1:5]
Aberfeldy Aberlour AnCnoc Ardbeg Ardmore
Aberfeldy NA NA NA NA NA
Aberlour 0.7086322 NA NA NA NA
AnCnoc 0.6973541 0.5030737 NA NA NA
Ardbeg -0.1473114 -0.2285909 -0.1404355 NA NA
Ardmore 0.7319024 0.5118338 0.5570195 0.2316174 NA
# Long-Format 0.8
d <- cor.mat %>%
as.data.frame() %>%
mutate(distillerry1 = whiskies$Distillery) %>%
gather(key = distillerry2, value = cor, -distillerry1) %>%
select(distillerry1, distillerry2, cor) %>%
filter(!is.na(cor) & cor >= 0.80)
head(d)
distillerry1 distillerry2 cor
1 Auchroisk Aberfeldy 0.8238415
2 Benrinnes Aberfeldy 0.8419479
3 Benromach Aberfeldy 0.8554217
# tbl_graph
g <- as_tbl_graph(d, directed = FALSE)
g
# A tbl_graph: 67 nodes and 135 edges
#
# An undirected simple graph with 1 component
#
# Node Data: 67 x 1 (active)
name
<chr>
1 Auchroisk
2 Benrinnes
# tbl_graph
g <- as_tbl_graph(d, directed = FALSE)
g
# A tbl_graph: 67 nodes and 135 edges
#
# An undirected simple graph with 1 component
#
# Node Data: 67 x 1 (active)
name
<chr>
1 Auchroisk
2 Benrinnes
3 Benromach
4 BlairAthol
5 RoyalLochnagar
6 Speyside
# ... with 61 more rows
#
# Edge Data: 135 x 3
from to cor
<int> <int> <dbl>
1 1 54 0.824
2 2 54 0.842
3 3 54 0.855
# ... with 132 more rows
3 Benromach
4 BlairAthol
5 RoyalLochnagar
6 Speyside
# ... with 61 more rows
#
# Edge Data: 135 x 3
from to cor
<int> <int> <dbl>
1 1 54 0.824
2 2 54 0.842
3 3 54 0.855
# ... with 132 more rows
#
g %>% igraph::graph.density()
[1] 0.06105834
#
g %>% igraph::transitivity()
[1] 0.2797927
# ( 1)
g %>% igraph::reciprocity()
[1] 1
#
g <- g %>%
mutate(centrality = centrality_betweenness())
g
# A tbl_graph: 67 nodes and 135 edges
#
# An undirected simple graph with 1 component
#
# Node Data: 67 x 2 (active)
name centrality
<chr> <dbl>
1 Auchroisk 174.
2 Benrinnes 122.
3 Benromach 411.
#
g <- g %E>%
mutate(centrality = centrality_edge_betweenness())
g
# A tbl_graph: 67 nodes and 135 edges
#
# An undirected simple graph with 1 component
#
# Edge Data: 135 x 4 (active)
from to cor centrality
<int> <int> <dbl> <dbl>
1 1 54 0.824 79.3
2 2 54 0.842 42.9
3 3 54 0.855 54.2
#
g <- g %E>%
mutate(centrality = centrality_edge_betweenness())
g
# A tbl_graph: 67 nodes and 135 edges
#
# An undirected simple graph with 1 component
#
# Edge Data: 135 x 4 (active)
from to cor centrality
<int> <int> <dbl> <dbl>
1 1 54 0.824 79.3
2 2 54 0.842 42.9
3 3 54 0.855 54.2
#
g <- g %>%
mutate(community = as.factor(group_fast_greedy(weights = cor)))
g
# A tbl_graph: 67 nodes and 135 edges
#
# An undirected simple graph with 1 component
#
# Node Data: 67 x 2 (active)
name community
<chr> <fct>
1 Auchroisk 2
2 Benrinnes 3
3 Benromach 2
g %>%
ggraph(layout = "kk")
g %>%
ggraph(layout = "kk") +
geom_edge_link(aes(width = cor),
alpha = 0.8,
colour = "lightgray")
g %>%
ggraph(layout = "kk") +
geom_edge_link(aes(width = cor),
alpha = 0.8,
colour = "lightgray") +
scale_edge_width(range = c(0.1, 1))
g %>%
ggraph(layout = "kk") +
geom_edge_link(aes(width = cor),
alpha = 0.8,
colour = "lightgray") +
scale_edge_width(range = c(0.1, 1)) +
geom_node_point(aes(colour = community, size = degree))
g %>%
ggraph(layout = "kk") +
geom_edge_link(aes(width = cor),
alpha = 0.8,
colour = "lightgray") +
scale_edge_width(range = c(0.1, 1)) +
geom_node_point(aes(colour = community, size = degree)) +
geom_node_text(aes(label = name), repel = TRUE)
g %>%
ggraph(layout = "kk") +
geom_edge_link(aes(width = cor),
alpha = 0.8,
colour = "lightgray") +
scale_edge_width(range = c(0.1, 1)) +
geom_node_point(aes(colour = community, size = degree)) +
geom_node_text(aes(label = name), repel = TRUE) +
theme_graph()
g %>%
ggraph(layout = "kk") +
geom_edge_arc(aes(width = cor),
alpha = 0.8,
colour = "lightgray") +
scale_edge_width(range = c(0.1, 1)) +
geom_node_point(aes(colour = community, size = degree)) +
theme_graph(background = "grey20", text_colour = "white")
g %>%
mutate(degree = centrality_degree(),
community = as.factor(group_fast_greedy(weights = cor))) %>%
filter(degree >= 6) %E>%
filter(cor > 0.85) %>%
ggraph(layout = "lgl") +
geom_edge_link(aes(width = cor),
alpha = 0.8,
colour = "lightgray") +
scale_edge_width(range = c(0.1, 1)) +
geom_node_point(aes(colour = community, size = degree)) +
geom_node_text(aes(label = name), repel = TRUE) +
theme_graph()
g %>% ggraph(layout = "kk") +
geom_edge_fan(aes(width = cor),
alpha = 0.8,
colour = "lightgray") +
scale_edge_width(range = c(0.1, 1)) +
geom_node_point(aes(colour = community, size = degree)) +
geom_node_text(aes(label = name), repel = TRUE) +
theme_graph()
g %>% ggraph(layout = "linear") +
geom_edge_arc(aes(width = cor),
alpha = 0.8,
colour = "lightgray") +
scale_edge_width(range = c(0.1, 1)) +
geom_node_point(aes(colour = community, size = degree)) +
geom_node_text(aes(label = name), repel = TRUE) +
theme_graph()
g %>% ggraph(layout = "linear", circular = TRUE) +
geom_edge_arc(aes(width = cor),
alpha = 0.8,
colour = "lightgray") +
scale_edge_width(range = c(0.1, 1)) +
geom_node_point(aes(colour = community, size = degree)) +
geom_node_text(aes(label = name), repel = TRUE) +
theme_graph()
#
d <- whiskies %>%
select(Body, Sweetness, Smoky, Medicinal, Tobacco, Honey,
Spicy, Winey, Nutty, Malty, Fruity, Floral) %>%
dist()
#
hc <- hclust(d, method="ward.D2")
# tbl_graph
g <- as_tbl_graph(hc)
g %>%
ggraph(layout = "kk") +
geom_edge_link(aes(width = cor),
alpha = 0.8,
colour = "lightgray") +
scale_edge_width(range = c(0.1, 1)) +
geom_node_point(aes(colour = community, size = degree)) +
geom_node_text(aes(label = name), repel = TRUE) +
theme_graph()
Whisky Correlation Network
Whisky Correlation Network
Whisky Correlation Network

More Related Content

What's hot

数学カフェ 確率・統計・機械学習回 「速習 確率・統計」
数学カフェ 確率・統計・機械学習回 「速習 確率・統計」数学カフェ 確率・統計・機械学習回 「速習 確率・統計」
数学カフェ 確率・統計・機械学習回 「速習 確率・統計」Ken'ichi Matsui
 
15分でわかる(範囲の)ベイズ統計学
15分でわかる(範囲の)ベイズ統計学15分でわかる(範囲の)ベイズ統計学
15分でわかる(範囲の)ベイズ統計学Ken'ichi Matsui
 
セクシー女優で学ぶ画像分類入門
セクシー女優で学ぶ画像分類入門セクシー女優で学ぶ画像分類入門
セクシー女優で学ぶ画像分類入門Takami Sato
 
はじめてのパターン認識 第1章
はじめてのパターン認識 第1章はじめてのパターン認識 第1章
はじめてのパターン認識 第1章Prunus 1350
 
言語と画像の表現学習
言語と画像の表現学習言語と画像の表現学習
言語と画像の表現学習Yuki Noguchi
 
変分推論法(変分ベイズ法)(PRML第10章)
変分推論法(変分ベイズ法)(PRML第10章)変分推論法(変分ベイズ法)(PRML第10章)
変分推論法(変分ベイズ法)(PRML第10章)Takao Yamanaka
 
ブートストラップ法とその周辺とR
ブートストラップ法とその周辺とRブートストラップ法とその周辺とR
ブートストラップ法とその周辺とRDaisuke Yoneoka
 
グラフィカルモデル入門
グラフィカルモデル入門グラフィカルモデル入門
グラフィカルモデル入門Kawamoto_Kazuhiko
 
Rで学ぶ回帰分析と単位根検定
Rで学ぶ回帰分析と単位根検定Rで学ぶ回帰分析と単位根検定
Rで学ぶ回帰分析と単位根検定Nagi Teramo
 
データサイエンス概論第一 5 時系列データの解析
データサイエンス概論第一 5 時系列データの解析データサイエンス概論第一 5 時系列データの解析
データサイエンス概論第一 5 時系列データの解析Seiichi Uchida
 
集中不等式のすすめ [集中不等式本読み会#1]
集中不等式のすすめ [集中不等式本読み会#1]集中不等式のすすめ [集中不等式本読み会#1]
集中不等式のすすめ [集中不等式本読み会#1]Kentaro Minami
 
漸近理論をスライド1枚で(フォローアッププログラムクラス講義07132016)
漸近理論をスライド1枚で(フォローアッププログラムクラス講義07132016)漸近理論をスライド1枚で(フォローアッププログラムクラス講義07132016)
漸近理論をスライド1枚で(フォローアッププログラムクラス講義07132016)Hideo Hirose
 
比例ハザードモデルはとってもtricky!
比例ハザードモデルはとってもtricky!比例ハザードモデルはとってもtricky!
比例ハザードモデルはとってもtricky!takehikoihayashi
 
カップルが一緒にお風呂に入る割合をベイズ推定してみた
カップルが一緒にお風呂に入る割合をベイズ推定してみたカップルが一緒にお風呂に入る割合をベイズ推定してみた
カップルが一緒にお風呂に入る割合をベイズ推定してみたhoxo_m
 
Counterfaual Machine Learning(CFML)のサーベイ
Counterfaual Machine Learning(CFML)のサーベイCounterfaual Machine Learning(CFML)のサーベイ
Counterfaual Machine Learning(CFML)のサーベイARISE analytics
 
20130716 はじパタ3章前半 ベイズの識別規則
20130716 はじパタ3章前半 ベイズの識別規則20130716 はじパタ3章前半 ベイズの識別規則
20130716 はじパタ3章前半 ベイズの識別規則koba cky
 
第4回DARM勉強会 (構造方程式モデリング)
第4回DARM勉強会 (構造方程式モデリング)第4回DARM勉強会 (構造方程式モデリング)
第4回DARM勉強会 (構造方程式モデリング)Yoshitake Takebayashi
 

What's hot (20)

数学カフェ 確率・統計・機械学習回 「速習 確率・統計」
数学カフェ 確率・統計・機械学習回 「速習 確率・統計」数学カフェ 確率・統計・機械学習回 「速習 確率・統計」
数学カフェ 確率・統計・機械学習回 「速習 確率・統計」
 
一般化線形モデル (GLM) & 一般化加法モデル(GAM)
一般化線形モデル (GLM) & 一般化加法モデル(GAM) 一般化線形モデル (GLM) & 一般化加法モデル(GAM)
一般化線形モデル (GLM) & 一般化加法モデル(GAM)
 
15分でわかる(範囲の)ベイズ統計学
15分でわかる(範囲の)ベイズ統計学15分でわかる(範囲の)ベイズ統計学
15分でわかる(範囲の)ベイズ統計学
 
セクシー女優で学ぶ画像分類入門
セクシー女優で学ぶ画像分類入門セクシー女優で学ぶ画像分類入門
セクシー女優で学ぶ画像分類入門
 
はじめてのパターン認識 第1章
はじめてのパターン認識 第1章はじめてのパターン認識 第1章
はじめてのパターン認識 第1章
 
言語と画像の表現学習
言語と画像の表現学習言語と画像の表現学習
言語と画像の表現学習
 
変分推論法(変分ベイズ法)(PRML第10章)
変分推論法(変分ベイズ法)(PRML第10章)変分推論法(変分ベイズ法)(PRML第10章)
変分推論法(変分ベイズ法)(PRML第10章)
 
主成分分析
主成分分析主成分分析
主成分分析
 
ブートストラップ法とその周辺とR
ブートストラップ法とその周辺とRブートストラップ法とその周辺とR
ブートストラップ法とその周辺とR
 
グラフィカルモデル入門
グラフィカルモデル入門グラフィカルモデル入門
グラフィカルモデル入門
 
Rで学ぶ回帰分析と単位根検定
Rで学ぶ回帰分析と単位根検定Rで学ぶ回帰分析と単位根検定
Rで学ぶ回帰分析と単位根検定
 
データサイエンス概論第一 5 時系列データの解析
データサイエンス概論第一 5 時系列データの解析データサイエンス概論第一 5 時系列データの解析
データサイエンス概論第一 5 時系列データの解析
 
集中不等式のすすめ [集中不等式本読み会#1]
集中不等式のすすめ [集中不等式本読み会#1]集中不等式のすすめ [集中不等式本読み会#1]
集中不等式のすすめ [集中不等式本読み会#1]
 
漸近理論をスライド1枚で(フォローアッププログラムクラス講義07132016)
漸近理論をスライド1枚で(フォローアッププログラムクラス講義07132016)漸近理論をスライド1枚で(フォローアッププログラムクラス講義07132016)
漸近理論をスライド1枚で(フォローアッププログラムクラス講義07132016)
 
比例ハザードモデルはとってもtricky!
比例ハザードモデルはとってもtricky!比例ハザードモデルはとってもtricky!
比例ハザードモデルはとってもtricky!
 
カップルが一緒にお風呂に入る割合をベイズ推定してみた
カップルが一緒にお風呂に入る割合をベイズ推定してみたカップルが一緒にお風呂に入る割合をベイズ推定してみた
カップルが一緒にお風呂に入る割合をベイズ推定してみた
 
BlackBox モデルの説明性・解釈性技術の実装
BlackBox モデルの説明性・解釈性技術の実装BlackBox モデルの説明性・解釈性技術の実装
BlackBox モデルの説明性・解釈性技術の実装
 
Counterfaual Machine Learning(CFML)のサーベイ
Counterfaual Machine Learning(CFML)のサーベイCounterfaual Machine Learning(CFML)のサーベイ
Counterfaual Machine Learning(CFML)のサーベイ
 
20130716 はじパタ3章前半 ベイズの識別規則
20130716 はじパタ3章前半 ベイズの識別規則20130716 はじパタ3章前半 ベイズの識別規則
20130716 はじパタ3章前半 ベイズの識別規則
 
第4回DARM勉強会 (構造方程式モデリング)
第4回DARM勉強会 (構造方程式モデリング)第4回DARM勉強会 (構造方程式モデリング)
第4回DARM勉強会 (構造方程式モデリング)
 

Similar to Whisky Correlation Network

An example of R code for Data visualization
An example of R code for Data visualizationAn example of R code for Data visualization
An example of R code for Data visualizationLiang (Leon) Zhou
 
Advanced Data Visualization Examples with R-Part II
Advanced Data Visualization Examples with R-Part IIAdvanced Data Visualization Examples with R-Part II
Advanced Data Visualization Examples with R-Part IIDr. Volkan OBAN
 
Advanced Data Visualization in R- Somes Examples.
Advanced Data Visualization in R- Somes Examples.Advanced Data Visualization in R- Somes Examples.
Advanced Data Visualization in R- Somes Examples.Dr. Volkan OBAN
 
MH prediction modeling and validation in r (2) classification 190709
MH prediction modeling and validation in r (2) classification 190709MH prediction modeling and validation in r (2) classification 190709
MH prediction modeling and validation in r (2) classification 190709Min-hyung Kim
 
Meetup Analytics with R and Neo4j
Meetup Analytics with R and Neo4jMeetup Analytics with R and Neo4j
Meetup Analytics with R and Neo4jNeo4j
 
Lois de kirchhoff, dipôles électrocinétiques
Lois de kirchhoff, dipôles électrocinétiquesLois de kirchhoff, dipôles électrocinétiques
Lois de kirchhoff, dipôles électrocinétiquesAchraf Ourti
 
Using a mobile phone as a therapist - Superweek 2018
Using a mobile phone as a therapist - Superweek 2018Using a mobile phone as a therapist - Superweek 2018
Using a mobile phone as a therapist - Superweek 2018Peter Meyer
 
Let’s Talk About Ruby
Let’s Talk About RubyLet’s Talk About Ruby
Let’s Talk About RubyIan Bishop
 
PLOTCON NYC: Behind Every Great Plot There's a Great Deal of Wrangling
PLOTCON NYC: Behind Every Great Plot There's a Great Deal of WranglingPLOTCON NYC: Behind Every Great Plot There's a Great Deal of Wrangling
PLOTCON NYC: Behind Every Great Plot There's a Great Deal of WranglingPlotly
 
Data visualization-2.1
Data visualization-2.1Data visualization-2.1
Data visualization-2.1RenukaRajmohan
 

Similar to Whisky Correlation Network (20)

Joclad 2010 d
Joclad 2010 dJoclad 2010 d
Joclad 2010 d
 
An example of R code for Data visualization
An example of R code for Data visualizationAn example of R code for Data visualization
An example of R code for Data visualization
 
Advanced Data Visualization Examples with R-Part II
Advanced Data Visualization Examples with R-Part IIAdvanced Data Visualization Examples with R-Part II
Advanced Data Visualization Examples with R-Part II
 
R for you
R for youR for you
R for you
 
R programming language
R programming languageR programming language
R programming language
 
Advanced Data Visualization in R- Somes Examples.
Advanced Data Visualization in R- Somes Examples.Advanced Data Visualization in R- Somes Examples.
Advanced Data Visualization in R- Somes Examples.
 
data-visualization.pdf
data-visualization.pdfdata-visualization.pdf
data-visualization.pdf
 
dplyr use case
dplyr use casedplyr use case
dplyr use case
 
RBootcamp Day 4
RBootcamp Day 4RBootcamp Day 4
RBootcamp Day 4
 
MH prediction modeling and validation in r (2) classification 190709
MH prediction modeling and validation in r (2) classification 190709MH prediction modeling and validation in r (2) classification 190709
MH prediction modeling and validation in r (2) classification 190709
 
Introduction to R
Introduction to RIntroduction to R
Introduction to R
 
Meetup Analytics with R and Neo4j
Meetup Analytics with R and Neo4jMeetup Analytics with R and Neo4j
Meetup Analytics with R and Neo4j
 
Lois de kirchhoff, dipôles électrocinétiques
Lois de kirchhoff, dipôles électrocinétiquesLois de kirchhoff, dipôles électrocinétiques
Lois de kirchhoff, dipôles électrocinétiques
 
Using a mobile phone as a therapist - Superweek 2018
Using a mobile phone as a therapist - Superweek 2018Using a mobile phone as a therapist - Superweek 2018
Using a mobile phone as a therapist - Superweek 2018
 
Let’s Talk About Ruby
Let’s Talk About RubyLet’s Talk About Ruby
Let’s Talk About Ruby
 
dplyr
dplyrdplyr
dplyr
 
PLOTCON NYC: Behind Every Great Plot There's a Great Deal of Wrangling
PLOTCON NYC: Behind Every Great Plot There's a Great Deal of WranglingPLOTCON NYC: Behind Every Great Plot There's a Great Deal of Wrangling
PLOTCON NYC: Behind Every Great Plot There's a Great Deal of Wrangling
 
CLUSTERGRAM
CLUSTERGRAMCLUSTERGRAM
CLUSTERGRAM
 
A Shiny Example-- R
A Shiny Example-- RA Shiny Example-- R
A Shiny Example-- R
 
Data visualization-2.1
Data visualization-2.1Data visualization-2.1
Data visualization-2.1
 

More from Takashi Kitano

好みの日本酒を呑みたい! 〜さけのわデータで探す自分好みの酒〜
好みの日本酒を呑みたい! 〜さけのわデータで探す自分好みの酒〜好みの日本酒を呑みたい! 〜さけのわデータで探す自分好みの酒〜
好みの日本酒を呑みたい! 〜さけのわデータで探す自分好みの酒〜Takashi Kitano
 
{shiny}と{leaflet}による地図アプリ開発Tips
{shiny}と{leaflet}による地図アプリ開発Tips{shiny}と{leaflet}による地図アプリ開発Tips
{shiny}と{leaflet}による地図アプリ開発TipsTakashi Kitano
 
令和から本気出す
令和から本気出す令和から本気出す
令和から本気出すTakashi Kitano
 
20170923 excelユーザーのためのr入門
20170923 excelユーザーのためのr入門20170923 excelユーザーのためのr入門
20170923 excelユーザーのためのr入門Takashi Kitano
 
mxnetで頑張る深層学習
mxnetで頑張る深層学習mxnetで頑張る深層学習
mxnetで頑張る深層学習Takashi Kitano
 
可視化周辺の進化がヤヴァイ 〜2016〜
可視化周辺の進化がヤヴァイ 〜2016〜可視化周辺の進化がヤヴァイ 〜2016〜
可視化周辺の進化がヤヴァイ 〜2016〜Takashi Kitano
 
Rによるウイスキー分析
Rによるウイスキー分析Rによるウイスキー分析
Rによるウイスキー分析Takashi Kitano
 
20160311 基礎からのベイズ統計学輪読会第6章 公開ver
20160311 基礎からのベイズ統計学輪読会第6章 公開ver20160311 基礎からのベイズ統計学輪読会第6章 公開ver
20160311 基礎からのベイズ統計学輪読会第6章 公開verTakashi Kitano
 
20140625 rでのデータ分析(仮) for_tokyor
20140625 rでのデータ分析(仮) for_tokyor20140625 rでのデータ分析(仮) for_tokyor
20140625 rでのデータ分析(仮) for_tokyorTakashi Kitano
 
lubridateパッケージ入門
lubridateパッケージ入門lubridateパッケージ入門
lubridateパッケージ入門Takashi Kitano
 
Google's r style guideのすゝめ
Google's r style guideのすゝめGoogle's r style guideのすゝめ
Google's r style guideのすゝめTakashi Kitano
 

More from Takashi Kitano (13)

好みの日本酒を呑みたい! 〜さけのわデータで探す自分好みの酒〜
好みの日本酒を呑みたい! 〜さけのわデータで探す自分好みの酒〜好みの日本酒を呑みたい! 〜さけのわデータで探す自分好みの酒〜
好みの日本酒を呑みたい! 〜さけのわデータで探す自分好みの酒〜
 
{shiny}と{leaflet}による地図アプリ開発Tips
{shiny}と{leaflet}による地図アプリ開発Tips{shiny}と{leaflet}による地図アプリ開発Tips
{shiny}と{leaflet}による地図アプリ開発Tips
 
令和から本気出す
令和から本気出す令和から本気出す
令和から本気出す
 
20170923 excelユーザーのためのr入門
20170923 excelユーザーのためのr入門20170923 excelユーザーのためのr入門
20170923 excelユーザーのためのr入門
 
mxnetで頑張る深層学習
mxnetで頑張る深層学習mxnetで頑張る深層学習
mxnetで頑張る深層学習
 
可視化周辺の進化がヤヴァイ 〜2016〜
可視化周辺の進化がヤヴァイ 〜2016〜可視化周辺の進化がヤヴァイ 〜2016〜
可視化周辺の進化がヤヴァイ 〜2016〜
 
Rによるウイスキー分析
Rによるウイスキー分析Rによるウイスキー分析
Rによるウイスキー分析
 
20160311 基礎からのベイズ統計学輪読会第6章 公開ver
20160311 基礎からのベイズ統計学輪読会第6章 公開ver20160311 基礎からのベイズ統計学輪読会第6章 公開ver
20160311 基礎からのベイズ統計学輪読会第6章 公開ver
 
20140625 rでのデータ分析(仮) for_tokyor
20140625 rでのデータ分析(仮) for_tokyor20140625 rでのデータ分析(仮) for_tokyor
20140625 rでのデータ分析(仮) for_tokyor
 
lubridateパッケージ入門
lubridateパッケージ入門lubridateパッケージ入門
lubridateパッケージ入門
 
20150329 tokyo r47
20150329 tokyo r4720150329 tokyo r47
20150329 tokyo r47
 
20140920 tokyo r43
20140920 tokyo r4320140920 tokyo r43
20140920 tokyo r43
 
Google's r style guideのすゝめ
Google's r style guideのすゝめGoogle's r style guideのすゝめ
Google's r style guideのすゝめ
 

Recently uploaded

毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degreeyuu sss
 
Student profile product demonstration on grades, ability, well-being and mind...
Student profile product demonstration on grades, ability, well-being and mind...Student profile product demonstration on grades, ability, well-being and mind...
Student profile product demonstration on grades, ability, well-being and mind...Seán Kennedy
 
Predictive Analysis for Loan Default Presentation : Data Analysis Project PPT
Predictive Analysis for Loan Default  Presentation : Data Analysis Project PPTPredictive Analysis for Loan Default  Presentation : Data Analysis Project PPT
Predictive Analysis for Loan Default Presentation : Data Analysis Project PPTBoston Institute of Analytics
 
Decoding the Heart: Student Presentation on Heart Attack Prediction with Data...
Decoding the Heart: Student Presentation on Heart Attack Prediction with Data...Decoding the Heart: Student Presentation on Heart Attack Prediction with Data...
Decoding the Heart: Student Presentation on Heart Attack Prediction with Data...Boston Institute of Analytics
 
How we prevented account sharing with MFA
How we prevented account sharing with MFAHow we prevented account sharing with MFA
How we prevented account sharing with MFAAndrei Kaleshka
 
ASML's Taxonomy Adventure by Daniel Canter
ASML's Taxonomy Adventure by Daniel CanterASML's Taxonomy Adventure by Daniel Canter
ASML's Taxonomy Adventure by Daniel Cantervoginip
 
Biometric Authentication: The Evolution, Applications, Benefits and Challenge...
Biometric Authentication: The Evolution, Applications, Benefits and Challenge...Biometric Authentication: The Evolution, Applications, Benefits and Challenge...
Biometric Authentication: The Evolution, Applications, Benefits and Challenge...GQ Research
 
Easter Eggs From Star Wars and in cars 1 and 2
Easter Eggs From Star Wars and in cars 1 and 2Easter Eggs From Star Wars and in cars 1 and 2
Easter Eggs From Star Wars and in cars 1 and 217djon017
 
办美国阿肯色大学小石城分校毕业证成绩单pdf电子版制作修改#真实留信入库#永久存档#真实可查#diploma#degree
办美国阿肯色大学小石城分校毕业证成绩单pdf电子版制作修改#真实留信入库#永久存档#真实可查#diploma#degree办美国阿肯色大学小石城分校毕业证成绩单pdf电子版制作修改#真实留信入库#永久存档#真实可查#diploma#degree
办美国阿肯色大学小石城分校毕业证成绩单pdf电子版制作修改#真实留信入库#永久存档#真实可查#diploma#degreeyuu sss
 
RadioAdProWritingCinderellabyButleri.pdf
RadioAdProWritingCinderellabyButleri.pdfRadioAdProWritingCinderellabyButleri.pdf
RadioAdProWritingCinderellabyButleri.pdfgstagge
 
Learn How Data Science Changes Our World
Learn How Data Science Changes Our WorldLearn How Data Science Changes Our World
Learn How Data Science Changes Our WorldEduminds Learning
 
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理科罗拉多大学波尔得分校毕业证学位证成绩单-可办理
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理e4aez8ss
 
Minimizing AI Hallucinations/Confabulations and the Path towards AGI with Exa...
Minimizing AI Hallucinations/Confabulations and the Path towards AGI with Exa...Minimizing AI Hallucinations/Confabulations and the Path towards AGI with Exa...
Minimizing AI Hallucinations/Confabulations and the Path towards AGI with Exa...Thomas Poetter
 
modul pembelajaran robotic Workshop _ by Slidesgo.pptx
modul pembelajaran robotic Workshop _ by Slidesgo.pptxmodul pembelajaran robotic Workshop _ by Slidesgo.pptx
modul pembelajaran robotic Workshop _ by Slidesgo.pptxaleedritatuxx
 
detection and classification of knee osteoarthritis.pptx
detection and classification of knee osteoarthritis.pptxdetection and classification of knee osteoarthritis.pptx
detection and classification of knee osteoarthritis.pptxAleenaJamil4
 
Generative AI for Social Good at Open Data Science East 2024
Generative AI for Social Good at Open Data Science East 2024Generative AI for Social Good at Open Data Science East 2024
Generative AI for Social Good at Open Data Science East 2024Colleen Farrelly
 
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhi
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝DelhiRS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhi
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhijennyeacort
 
GA4 Without Cookies [Measure Camp AMS]
GA4 Without Cookies [Measure Camp AMS]GA4 Without Cookies [Measure Camp AMS]
GA4 Without Cookies [Measure Camp AMS]📊 Markus Baersch
 
Vision, Mission, Goals and Objectives ppt..pptx
Vision, Mission, Goals and Objectives ppt..pptxVision, Mission, Goals and Objectives ppt..pptx
Vision, Mission, Goals and Objectives ppt..pptxellehsormae
 
Defining Constituents, Data Vizzes and Telling a Data Story
Defining Constituents, Data Vizzes and Telling a Data StoryDefining Constituents, Data Vizzes and Telling a Data Story
Defining Constituents, Data Vizzes and Telling a Data StoryJeremy Anderson
 

Recently uploaded (20)

毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
 
Student profile product demonstration on grades, ability, well-being and mind...
Student profile product demonstration on grades, ability, well-being and mind...Student profile product demonstration on grades, ability, well-being and mind...
Student profile product demonstration on grades, ability, well-being and mind...
 
Predictive Analysis for Loan Default Presentation : Data Analysis Project PPT
Predictive Analysis for Loan Default  Presentation : Data Analysis Project PPTPredictive Analysis for Loan Default  Presentation : Data Analysis Project PPT
Predictive Analysis for Loan Default Presentation : Data Analysis Project PPT
 
Decoding the Heart: Student Presentation on Heart Attack Prediction with Data...
Decoding the Heart: Student Presentation on Heart Attack Prediction with Data...Decoding the Heart: Student Presentation on Heart Attack Prediction with Data...
Decoding the Heart: Student Presentation on Heart Attack Prediction with Data...
 
How we prevented account sharing with MFA
How we prevented account sharing with MFAHow we prevented account sharing with MFA
How we prevented account sharing with MFA
 
ASML's Taxonomy Adventure by Daniel Canter
ASML's Taxonomy Adventure by Daniel CanterASML's Taxonomy Adventure by Daniel Canter
ASML's Taxonomy Adventure by Daniel Canter
 
Biometric Authentication: The Evolution, Applications, Benefits and Challenge...
Biometric Authentication: The Evolution, Applications, Benefits and Challenge...Biometric Authentication: The Evolution, Applications, Benefits and Challenge...
Biometric Authentication: The Evolution, Applications, Benefits and Challenge...
 
Easter Eggs From Star Wars and in cars 1 and 2
Easter Eggs From Star Wars and in cars 1 and 2Easter Eggs From Star Wars and in cars 1 and 2
Easter Eggs From Star Wars and in cars 1 and 2
 
办美国阿肯色大学小石城分校毕业证成绩单pdf电子版制作修改#真实留信入库#永久存档#真实可查#diploma#degree
办美国阿肯色大学小石城分校毕业证成绩单pdf电子版制作修改#真实留信入库#永久存档#真实可查#diploma#degree办美国阿肯色大学小石城分校毕业证成绩单pdf电子版制作修改#真实留信入库#永久存档#真实可查#diploma#degree
办美国阿肯色大学小石城分校毕业证成绩单pdf电子版制作修改#真实留信入库#永久存档#真实可查#diploma#degree
 
RadioAdProWritingCinderellabyButleri.pdf
RadioAdProWritingCinderellabyButleri.pdfRadioAdProWritingCinderellabyButleri.pdf
RadioAdProWritingCinderellabyButleri.pdf
 
Learn How Data Science Changes Our World
Learn How Data Science Changes Our WorldLearn How Data Science Changes Our World
Learn How Data Science Changes Our World
 
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理科罗拉多大学波尔得分校毕业证学位证成绩单-可办理
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理
 
Minimizing AI Hallucinations/Confabulations and the Path towards AGI with Exa...
Minimizing AI Hallucinations/Confabulations and the Path towards AGI with Exa...Minimizing AI Hallucinations/Confabulations and the Path towards AGI with Exa...
Minimizing AI Hallucinations/Confabulations and the Path towards AGI with Exa...
 
modul pembelajaran robotic Workshop _ by Slidesgo.pptx
modul pembelajaran robotic Workshop _ by Slidesgo.pptxmodul pembelajaran robotic Workshop _ by Slidesgo.pptx
modul pembelajaran robotic Workshop _ by Slidesgo.pptx
 
detection and classification of knee osteoarthritis.pptx
detection and classification of knee osteoarthritis.pptxdetection and classification of knee osteoarthritis.pptx
detection and classification of knee osteoarthritis.pptx
 
Generative AI for Social Good at Open Data Science East 2024
Generative AI for Social Good at Open Data Science East 2024Generative AI for Social Good at Open Data Science East 2024
Generative AI for Social Good at Open Data Science East 2024
 
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhi
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝DelhiRS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhi
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhi
 
GA4 Without Cookies [Measure Camp AMS]
GA4 Without Cookies [Measure Camp AMS]GA4 Without Cookies [Measure Camp AMS]
GA4 Without Cookies [Measure Camp AMS]
 
Vision, Mission, Goals and Objectives ppt..pptx
Vision, Mission, Goals and Objectives ppt..pptxVision, Mission, Goals and Objectives ppt..pptx
Vision, Mission, Goals and Objectives ppt..pptx
 
Defining Constituents, Data Vizzes and Telling a Data Story
Defining Constituents, Data Vizzes and Telling a Data StoryDefining Constituents, Data Vizzes and Telling a Data Story
Defining Constituents, Data Vizzes and Telling a Data Story
 

Whisky Correlation Network

  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 7.
  • 8.
  • 9. 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 A B B C C E D B E D E F
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16. # whiskies <- data.table::fread("http:// outreach.mathstat.strath.ac.uk/outreach/nessie/datasets/ whiskies.txt", header = TRUE) # cor.mat <- whiskies %>% select(Body, Sweetness, Smoky, Medicinal, Tobacco, Honey, Spicy, Winey, Nutty, Malty, Fruity, Floral) %>% t() %>% cor()
  • 17. # colnames(cor.mat) <- whiskies$Distillery rownames(cor.mat) <- whiskies$Distillery # cor.mat[upper.tri(cor.mat, diag = TRUE)] <- NA cor.mat[1:5, 1:5] Aberfeldy Aberlour AnCnoc Ardbeg Ardmore Aberfeldy NA NA NA NA NA Aberlour 0.7086322 NA NA NA NA AnCnoc 0.6973541 0.5030737 NA NA NA Ardbeg -0.1473114 -0.2285909 -0.1404355 NA NA Ardmore 0.7319024 0.5118338 0.5570195 0.2316174 NA
  • 18. # Long-Format 0.8 d <- cor.mat %>% as.data.frame() %>% mutate(distillerry1 = whiskies$Distillery) %>% gather(key = distillerry2, value = cor, -distillerry1) %>% select(distillerry1, distillerry2, cor) %>% filter(!is.na(cor) & cor >= 0.80) head(d) distillerry1 distillerry2 cor 1 Auchroisk Aberfeldy 0.8238415 2 Benrinnes Aberfeldy 0.8419479 3 Benromach Aberfeldy 0.8554217
  • 19.
  • 20. # tbl_graph g <- as_tbl_graph(d, directed = FALSE) g # A tbl_graph: 67 nodes and 135 edges # # An undirected simple graph with 1 component # # Node Data: 67 x 1 (active) name <chr> 1 Auchroisk 2 Benrinnes
  • 21. # tbl_graph g <- as_tbl_graph(d, directed = FALSE) g # A tbl_graph: 67 nodes and 135 edges # # An undirected simple graph with 1 component # # Node Data: 67 x 1 (active) name <chr> 1 Auchroisk 2 Benrinnes
  • 22. 3 Benromach 4 BlairAthol 5 RoyalLochnagar 6 Speyside # ... with 61 more rows # # Edge Data: 135 x 3 from to cor <int> <int> <dbl> 1 1 54 0.824 2 2 54 0.842 3 3 54 0.855 # ... with 132 more rows
  • 23. 3 Benromach 4 BlairAthol 5 RoyalLochnagar 6 Speyside # ... with 61 more rows # # Edge Data: 135 x 3 from to cor <int> <int> <dbl> 1 1 54 0.824 2 2 54 0.842 3 3 54 0.855 # ... with 132 more rows
  • 24. # g %>% igraph::graph.density() [1] 0.06105834 # g %>% igraph::transitivity() [1] 0.2797927 # ( 1) g %>% igraph::reciprocity() [1] 1
  • 25. # g <- g %>% mutate(centrality = centrality_betweenness()) g # A tbl_graph: 67 nodes and 135 edges # # An undirected simple graph with 1 component # # Node Data: 67 x 2 (active) name centrality <chr> <dbl> 1 Auchroisk 174. 2 Benrinnes 122. 3 Benromach 411.
  • 26. # g <- g %E>% mutate(centrality = centrality_edge_betweenness()) g # A tbl_graph: 67 nodes and 135 edges # # An undirected simple graph with 1 component # # Edge Data: 135 x 4 (active) from to cor centrality <int> <int> <dbl> <dbl> 1 1 54 0.824 79.3 2 2 54 0.842 42.9 3 3 54 0.855 54.2
  • 27. # g <- g %E>% mutate(centrality = centrality_edge_betweenness()) g # A tbl_graph: 67 nodes and 135 edges # # An undirected simple graph with 1 component # # Edge Data: 135 x 4 (active) from to cor centrality <int> <int> <dbl> <dbl> 1 1 54 0.824 79.3 2 2 54 0.842 42.9 3 3 54 0.855 54.2
  • 28. # g <- g %>% mutate(community = as.factor(group_fast_greedy(weights = cor))) g # A tbl_graph: 67 nodes and 135 edges # # An undirected simple graph with 1 component # # Node Data: 67 x 2 (active) name community <chr> <fct> 1 Auchroisk 2 2 Benrinnes 3 3 Benromach 2
  • 29.
  • 31.
  • 32. g %>% ggraph(layout = "kk") + geom_edge_link(aes(width = cor), alpha = 0.8, colour = "lightgray")
  • 33.
  • 34. g %>% ggraph(layout = "kk") + geom_edge_link(aes(width = cor), alpha = 0.8, colour = "lightgray") + scale_edge_width(range = c(0.1, 1))
  • 35.
  • 36. g %>% ggraph(layout = "kk") + geom_edge_link(aes(width = cor), alpha = 0.8, colour = "lightgray") + scale_edge_width(range = c(0.1, 1)) + geom_node_point(aes(colour = community, size = degree))
  • 37.
  • 38. g %>% ggraph(layout = "kk") + geom_edge_link(aes(width = cor), alpha = 0.8, colour = "lightgray") + scale_edge_width(range = c(0.1, 1)) + geom_node_point(aes(colour = community, size = degree)) + geom_node_text(aes(label = name), repel = TRUE)
  • 39.
  • 40. g %>% ggraph(layout = "kk") + geom_edge_link(aes(width = cor), alpha = 0.8, colour = "lightgray") + scale_edge_width(range = c(0.1, 1)) + geom_node_point(aes(colour = community, size = degree)) + geom_node_text(aes(label = name), repel = TRUE) + theme_graph()
  • 41.
  • 42. g %>% ggraph(layout = "kk") + geom_edge_arc(aes(width = cor), alpha = 0.8, colour = "lightgray") + scale_edge_width(range = c(0.1, 1)) + geom_node_point(aes(colour = community, size = degree)) + theme_graph(background = "grey20", text_colour = "white")
  • 43.
  • 44.
  • 45. g %>% mutate(degree = centrality_degree(), community = as.factor(group_fast_greedy(weights = cor))) %>% filter(degree >= 6) %E>% filter(cor > 0.85) %>% ggraph(layout = "lgl") + geom_edge_link(aes(width = cor), alpha = 0.8, colour = "lightgray") + scale_edge_width(range = c(0.1, 1)) + geom_node_point(aes(colour = community, size = degree)) + geom_node_text(aes(label = name), repel = TRUE) + theme_graph()
  • 46. g %>% ggraph(layout = "kk") + geom_edge_fan(aes(width = cor), alpha = 0.8, colour = "lightgray") + scale_edge_width(range = c(0.1, 1)) + geom_node_point(aes(colour = community, size = degree)) + geom_node_text(aes(label = name), repel = TRUE) + theme_graph()
  • 47. g %>% ggraph(layout = "linear") + geom_edge_arc(aes(width = cor), alpha = 0.8, colour = "lightgray") + scale_edge_width(range = c(0.1, 1)) + geom_node_point(aes(colour = community, size = degree)) + geom_node_text(aes(label = name), repel = TRUE) + theme_graph()
  • 48.
  • 49. g %>% ggraph(layout = "linear", circular = TRUE) + geom_edge_arc(aes(width = cor), alpha = 0.8, colour = "lightgray") + scale_edge_width(range = c(0.1, 1)) + geom_node_point(aes(colour = community, size = degree)) + geom_node_text(aes(label = name), repel = TRUE) + theme_graph()
  • 50.
  • 51. # d <- whiskies %>% select(Body, Sweetness, Smoky, Medicinal, Tobacco, Honey, Spicy, Winey, Nutty, Malty, Fruity, Floral) %>% dist() # hc <- hclust(d, method="ward.D2") # tbl_graph g <- as_tbl_graph(hc)
  • 52. g %>% ggraph(layout = "kk") + geom_edge_link(aes(width = cor), alpha = 0.8, colour = "lightgray") + scale_edge_width(range = c(0.1, 1)) + geom_node_point(aes(colour = community, size = degree)) + geom_node_text(aes(label = name), repel = TRUE) + theme_graph()