Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
ChatGPTにR言語を教えてもらう(仮)
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
NobuakiOshiro
PRO
March 18, 2023
Technology
1.3k
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
ChatGPTにR言語を教えてもらう(仮)
https://connpass.com/event/274084/
NobuakiOshiro
PRO
March 18, 2023
More Decks by NobuakiOshiro
See All by NobuakiOshiro
20261006締切_中東情勢週次報告_本編12枚_補足4枚_大城作成分
doradora09
PRO
0
25
20260929締切_中東情勢週次報告_BRS統合版_本編12枚_補足4枚_大城
doradora09
PRO
0
13
20260922締切_中東情勢_週次レポート_18枚_大城作成分
doradora09
PRO
1
52
20260915締切_中東情勢_初心者向け週次レポート_17枚_大城作成分
doradora09
PRO
0
40
20260912_codex+computerUse用のマシン購入を考える
doradora09
PRO
0
95
20260910_中東予測の過去予測のAI評価_統合報告スライド_10枚_大城
doradora09
PRO
0
19
20260826_中東情勢モニタリング_週次スライド統合_大城版_12p
doradora09
PRO
0
42
20260909_中東情勢モニタリング_週次スライド_10p_大城.pdf
doradora09
PRO
0
46
20260904_DeepResearchで実践する外部環境モニタリング
doradora09
PRO
0
59
Other Decks in Technology
See All in Technology
Google Cloud Next Tokyo 26登壇時のスクリプト
recruitengineers
PRO
0
210
オンラインゲームのシステム全体像 - コロプラ 2026年度 新卒研修
colopl
0
980
おそらく日本で唯一のDevRelインターン生として
husengs7
0
170
20260930_Gemma4_Hands-on
tsho
0
240
初対面のメンバーがチームを組み、Claude Codeでゼロからサービスをリリース
mkdev10
1
110
オブザーバビリティを高める AI エージェント体験を考える / Designing AI Agent Experiences That Enhance Observability
aoto
PRO
2
320
無理せず続ける、子育てエンジニアの学び
codmoninc
PRO
0
510
Datadog の学び方 - あるいは、オブザーバビリティを学ぶとは何か
mananyuki
1
510
不可逆な意思決定を避けながら10億超の顧客データを AI Ready にするデータ基盤設計
baseballyama
1
220
More Freedom on the Same Shared GPU Cluster: A Small Team’s Experience with vCluster
nttcom
0
140
LLM機能を自作して分かるSnowflake Cortex AIの強み
nayuts
0
330
AI駆動開発の時代になったのでトヨタ生産方式から見直す
terurou
5
5.4k
Featured
See All Featured
Utilizing Notion as your number one productivity tool
mfonobong
4
610
The Cost Of JavaScript in 2023
addyosmani
55
10k
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
2.2k
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.5k
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
2
400
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
350
Game over? The fight for quality and originality in the time of robots
wayneb77
1
300
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
420
Principles of Awesome APIs and How to Build Them.
keavy
128
18k
First, design no harm
axbom
PRO
2
1.3k
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
1.4k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
Transcript
ChatGPTʹRݴޠΛڭ͑ͯΒ͏ (Ծ) doradora09 2023-03-15
#{r, echo=F} #install.packages("tinytex") #tinytex::install_tinytex() #tinytex::tlmgr_install(c("collection-langjapanese", "pxrubrica")) # ΠϯτϩμΫγϣϯ ࣗݾհɿNOB DATAͷେͰ͢ɻࠓԬ͔Β͖ͬͯ·ͨ͠ɻ
ChatGPTɺΊͬͪΌ͍͢͝Ͱ͢ΑͶɻ https://openai.com/blog/chatgpt · · · 2/29
None
RݴޠͰͷࣗવݴޠॲཧσʔλੳͷՄೳੑ (by ChatGPT) ςΩετσʔλͷલॲཧղੳ͕༰қʹͰ͖Δ σʔλͷՄࢹԽ͕ڧྗͰɺଟ༷ͳάϥϑΟοΫεΛੜՄೳ ػցֶश౷ܭϞσϦϯάʹ๛ͳύοέʔδ͕ଘࡏ ΦʔϓϯιʔεͰɺੈքதͷ։ൃऀʹΑͬͯαϙʔτ͞Ε͍ͯΔ · · ·
· 3/29
ChatGPTΛͬͯRݴޠΛֶͿϝϦοτ(by ChatGPT) ࣗવݴޠͰ࣭Λ͔͚͛Δ͜ͱ͕Ͱ͖ΔͨΊɺཧղ͍͢͠ ࣭ʹର͢Δճ͕࣌ؒͰಘΒΕΔͨΊɺޮతͳֶश͕Մೳ ࣝΛ૿͚ͩ͢Ͱͳ͘ɺ࣮ࡍͷίʔσΟϯάͷղܾαϙʔτ ॳֶऀ͔Β্ڃऀ·Ͱɺ෯͍Ϩϕϧͷ࣭ʹରԠ · · · ·
4/29
େݸਓͱͯ͠ Γɺͷੳͷݟͱਓ຺ͱͯ͠ͷRݴޠˍίϛϡχςΟوॏ ଟɺR <-> PythonަྲྀChatGPTΛ͑ḿΔͣ(ࠓճׂѪ) ੳॳ৺ऀʹͱͬͯChatGPTྑ͍૬ʹͳΔͷͰʁ(σʔλڭҭɺࠓ ͪ͜Β) · · ·
5/29
ChatGPTΛͬͨRݴޠͷֶशํ๏ ChatGPTʹ࣭Λ͔͚͛ΔܗࣜͰਐΊͯΈΔ ྫ͑ɺʮirisσʔλͷαϯϓϧίʔυΛڭ͍͑ͯͩ͘͞ʯͱฉ͍ͨ߹ (ϖϯΪϯʹׂ͍ͭͯѪ) · · · 6/29
ChatGPTʹݴΘΕΔ͕··ɺirisσʔληοτΛ ͬͨσϞΛ࣮ߦ ### データの概要 head(iris) ## Sepal.Length Sepal.Width Petal.Length Petal.Width
Species ## 1 5.1 3.5 1.4 0.2 setosa ## 2 4.9 3.0 1.4 0.2 setosa ## 3 4.7 3.2 1.3 0.2 setosa ## 4 4.6 3.1 1.5 0.2 setosa ## 5 5.0 3.6 1.4 0.2 setosa ## 6 5.4 3.9 1.7 0.4 setosa 7/29
###基本的な統計量 summary(iris) ## Sepal.Length Sepal.Width Petal.Length Petal.Width ## Min. :4.300
Min. :2.000 Min. :1.000 Min. :0.100 ## 1st Qu.:5.100 1st Qu.:2.800 1st Qu.:1.600 1st Qu.:0.300 ## Median :5.800 Median :3.000 Median :4.350 Median :1.300 ## Mean :5.843 Mean :3.057 Mean :3.758 Mean :1.199 ## 3rd Qu.:6.400 3rd Qu.:3.300 3rd Qu.:5.100 3rd Qu.:1.800 ## Max. :7.900 Max. :4.400 Max. :6.900 Max. :2.500 ## Species ## setosa :50 ## versicolor:50 ## virginica :50 ## ## ## 8/29
###散布図行列 pairs(iris[, 1:4], main = "Iris Data", pch = 21,
bg = c("red", "green3", "blue") [unclass(iris$Species)]) 9/29
irisσʔληοτΛͬͨσϞᶄ ࣍ʹɺʮirisσʔληοτΛ༻͍ͯ༧ଌϞσϧΛߏங͍ͯͩ͘͠͞ʯͱฉ͍ͨ ߹ ॳֶऀͩͱʮ༧ଌϞσϧ࡞ΔʹͲ͏ͨ͠Β͍͍Ͱ͔͢ʁʯͱ͔ͷ࣭ྗ ඞཁ͔ · · 10/29
࣮ߦ # 必要なパッケージをインストール #install.packages("caret") #install.packages("rpart") # パッケージを読み込む library(caret) ## Loading
required package: ggplot2 ## Loading required package: lattice library(rpart) # データセットを学習データとテストデータに分割(例えば、75%を学習データ、25%をテストデータとする) set.seed(42) trainIndex <- createDataPartition(iris$Species, p = 0.75, list = FALSE) train_data <- iris[trainIndex, ] test_data <- iris[-trainIndex, ] # 決定木モデルを構築 model <- rpart(Species ~ ., data = train_data, method = "class") 11/29
# モデルの予測精度を評価 predictions <- predict(model, test_data, type = "class") confusionMatrix(predictions,
test_data$Species) ## Confusion Matrix and Statistics ## ## Reference ## Prediction setosa versicolor virginica ## setosa 12 0 0 ## versicolor 0 11 4 ## virginica 0 1 8 ## ## Overall Statistics ## ## Accuracy : 0.8611 ## 95% CI : (0.705, 0.9533) ## No Information Rate : 0.3333 ## P-Value [Acc > NIR] : 8.705e-11 ## ## Kappa : 0.7917 ## ## Mcnemar's Test P-Value : NA ## ## Statistics by Class: ## 12/29
irisσʔληοτΛͬͨσϞᶅ ࣍ʹɺʮ݁ՌΛ͔Γ͘͢ggplot2ͰՄࢹԽͯ͘͠Εʯͱݴͬͨ߹ · # 必要なパッケージをインストール #install.packages("ggplot2") #install.packages("GGally") # パッケージを読み込む library(ggplot2)
library(GGally) ## Registered S3 method overwritten by 'GGally': ## method from ## +.gg ggplot2 # テストデータに予測結果を追加 test_data$PredictedSpecies <- predictions # 散布図行列を作成 plot <- ggpairs( test_data, columns = 1:4, mapping = ggplot2::aes(color = PredictedSpecies, shape = Species), 13/29
print(plot) 14/29
irisσʔληοτΛͬͨσϞᶆ ઌ΄ͲͷίʔυΛೖΕͯɺਤͷݟํΛڭ͑ͯཉ͍͠ͱݴͬͨ߹ͷChatGPT ͷճɻίʔυͷղઆͯ͘͠ΕΔɻ · 15/29
irisσʔληοτΛͬͨσϞᶆ ઌ΄ͲͷίʔυΛೖΕͯɺਤͷݟํΛڭ͑ͯཉ͍͠ͱݴͬͨ߹ͷChatGPT ͷճɻίʔυͷղઆͯ͘͠ΕΔɻ · 16/29
શવ͕มΘͬͯࢥ͍͖ͭͰ͛ͯΈΔ ʮϩέοτͷ؆қγϛϡϨʔγϣϯΛͯ͠ཉ͍͠ʯɺͱݴͬͨ߹ͷίʔυ · ###ロケットの簡易シミュレーション(ChatGPTが教えてくれたver) # 定数 g <- 9.81 #
重力加速度 [m/s^2] mass <- 50 # ロケットの質量 [kg] thrust <- 1000 # ロケットの推力 [N] drag_coefficient <- 0.1 # 空気抵抗係数 air_density <- 1.225 # 空気密度 [kg/m^3] area <- 0.1 # ロケットの断面積 [m^2] # オイラー法による数値積分 time_step <- 0.1 # 時間ステップ [s] time <- seq(0, 10, time_step) velocity <- numeric(length(time)) position <- numeric(length(time)) 17/29
for (i in 2:length(time)) { drag_force <- 0.5 * drag_coefficient
* air_density * area * velocity[i - 1]^2 acceleration <- (thrust - mass * g - drag_force) / mass velocity[i] <- velocity[i - 1] + acceleration * time_step position[i] <- position[i - 1] + velocity[i - 1] * time_step } 18/29
࣮ߦ݁Ռͷϓϩοτ plot(time, position, type = "l", xlab = "Time [s]",
ylab = "Altitude [m]", main = "Rocket Launch Simulation") 19/29
ײ ී௨ʹಈ͘ɻ(͔͠ແअؾʹيಓܭࢉͰ͖Δɻ) ෳࡶͳͷͰͳ͚Εɺͱ͔͔ͬΓͱͯ͘͢͠͝ྑͦ͞͏ ࡉ͔͍͍ํͩͱʮ͜͏͍͏͜ͱΛ͍ͨ࣌͠ͷؔͷύϥϝʔλ໊ڭ͑ͯ͘ Εʯͱ͔͍͚Δͣ · · · 20/29
ิɿ࣮ߦڥʹ͍ͭͯ ͪͳΈʹڥߏஙͷํ๏ͱ͔ڭ͑ͯ͘Ε·͢ · 21/29
ิɿ࣮ߦڥʹ͍ͭͯ ͪͳΈʹڥߏஙͷํ๏ͱ͔ڭ͑ͯ͘Ε·͢ · 22/29
Τϥʔ͕ग़ͨ߹ ΤϥʔϝοηʔδΛChatGPTʹೖΕΔͱΑ͠ͳʹσόοάͯ͘͠Ε·͢ ͜ͷลݱঢ়·ͩී௨ʹϓϩάϥϛϯάݴޠͷ͕ࣝ͋ͬͨํ͕ૣ͍͔ (ͪΖΜকདྷతʹվળ͢ΔՄೳੑ͋Δ) · · · 23/29
ChatGPTΛֶͬͨशͷݶքͱҙ ChatGPT͕ৗʹਖ਼֬ͳใΛఏڙͰ͖ͳ͍͜ͱɺ࠷৽ͷใ͕ө͞Εͳ ͍Մೳੑ(2021·Ͱͷֶशσʔλ) ͠ΕͬͱӕΛͭ͘(ମײ20%͘Β͍) ҙɿ݁ߏͳׂ߹Ͱɺଘࡏ͠ͳ͍ॻ੶ͷհͳͲ͋Δ ଞͷࢿྉઐՈͷҙݟࢀর͢Δॏཁੑ · · · ·
24/29
ྫɿଘࡏ͠ͳ͍ॻ੶ͷϨίϝϯυ ͜Μͳײ͡Ͱɺ͠ΕͬͱҟͳΔใ͖ࠞͬͯ͟·͢ ಛʹॻ੶ͱ͔จʹ͍ͭͯཪऔΓ͕ඞཁ (Ұݟ߹ͬͯͦ͏Ͱ߹ͬͯͳ͍) · · 25/29
ΜͩΒr-wakalangͷօ͞Μʹ૬ஊɾɾʂʂ ͋Δछͷਓྗ൛ू߹ɻ͋Γ͕ͨɾɾ https://github.com/tokyor/r-wakalang ೖޱͱͯ͠ͷChatGPT׆༻͍͍͚ͲɺͪΌΜͱ༗ࣝऀʹ૬ஊ͠·͠ΐ͏ · · · 26/29
·ͱΊ ChatGPTɺศར RͰ͜͏͍͏͜ͱ͕Γ͍ͨɺͱ͔νϡʔτϦΞϧΛհͯ͘͠Εɺͱ͍͏ײ ͡ͰਐΊ͍ͯ͘ͷ͕٢ · · 27/29
͓·͚ ͜ͷൃදͷ༰ͷߏɺεϥΠυ͔ͷํ๏ɺαϯϓϧίʔυશ෦ChatGPT ʹฉ͖ͳ͕Β࡞ͯ͠ݟ·ͨ͠ ৭ʑͳֶशʹ͑Δͱࢥ͍·͢ͷͰɺੋඇɾɾʂʂ · · 28/29
Enjoy..!!