library(readr)
train <- read_csv("train.csv")
## Rows: 8693 Columns: 14
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (5): PassengerId, HomePlanet, Cabin, Destination, Name
## dbl (6): Age, RoomService, FoodCourt, ShoppingMall, Spa, VRDeck
## lgl (3): CryoSleep, VIP, Transported
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
library(readr)
test <- read_csv("test.csv")
## Rows: 4277 Columns: 13
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (5): PassengerId, HomePlanet, Cabin, Destination, Name
## dbl (6): Age, RoomService, FoodCourt, ShoppingMall, Spa, VRDeck
## lgl (2): CryoSleep, VIP
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.4 ✔ purrr 1.0.2
## ✔ forcats 1.0.0 ✔ stringr 1.5.1
## ✔ ggplot2 3.4.4 ✔ tibble 3.2.1
## ✔ lubridate 1.9.3 ✔ tidyr 1.3.0
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(explore)
library(dplyr)
library(DataExplorer)
train%>%describe_all()
## # A tibble: 14 × 8
## variable type na na_pct unique min mean max
## <chr> <chr> <int> <dbl> <int> <dbl> <dbl> <dbl>
## 1 PassengerId chr 0 0 8693 NA NA NA
## 2 HomePlanet chr 201 2.3 4 NA NA NA
## 3 CryoSleep lgl 217 2.5 3 0 0.36 1
## 4 Cabin chr 199 2.3 6561 NA NA NA
## 5 Destination chr 182 2.1 4 NA NA NA
## 6 Age dbl 179 2.1 81 0 28.8 79
## 7 VIP lgl 203 2.3 3 0 0.02 1
## 8 RoomService dbl 181 2.1 1274 0 225. 14327
## 9 FoodCourt dbl 183 2.1 1508 0 458. 29813
## 10 ShoppingMall dbl 208 2.4 1116 0 174. 23492
## 11 Spa dbl 183 2.1 1328 0 311. 22408
## 12 VRDeck dbl 188 2.2 1307 0 305. 24133
## 13 Name chr 200 2.3 8474 NA NA NA
## 14 Transported lgl 0 0 2 0 0.5 1
test%>%describe_all()
## # A tibble: 13 × 8
## variable type na na_pct unique min mean max
## <chr> <chr> <int> <dbl> <int> <dbl> <dbl> <dbl>
## 1 PassengerId chr 0 0 4277 NA NA NA
## 2 HomePlanet chr 87 2 4 NA NA NA
## 3 CryoSleep lgl 93 2.2 3 0 0.37 1
## 4 Cabin chr 100 2.3 3266 NA NA NA
## 5 Destination chr 92 2.2 4 NA NA NA
## 6 Age dbl 91 2.1 80 0 28.7 79
## 7 VIP lgl 93 2.2 3 0 0.02 1
## 8 RoomService dbl 82 1.9 843 0 219. 11567
## 9 FoodCourt dbl 106 2.5 903 0 439. 25273
## 10 ShoppingMall dbl 98 2.3 716 0 177. 8292
## 11 Spa dbl 101 2.4 834 0 303. 19844
## 12 VRDeck dbl 80 1.9 797 0 311. 22272
## 13 Name chr 94 2.2 4177 NA NA NA
create_report(train)
##
##
## processing file: report.rmd
##
|
| | 0%
|
|. | 2%
|
|.. | 5% [global_options]
|
|... | 7%
|
|.... | 10% [introduce]
|
|.... | 12%
|
|..... | 14% [plot_intro]
|
|...... | 17%
|
|....... | 19% [data_structure]
|
|........ | 21%
|
|......... | 24% [missing_profile]
|
|.......... | 26%
|
|........... | 29% [univariate_distribution_header]
|
|........... | 31%
|
|............ | 33% [plot_histogram]
|
|............. | 36%
|
|.............. | 38% [plot_density]
|
|............... | 40%
|
|................ | 43% [plot_frequency_bar]
|
|................. | 45%
|
|.................. | 48% [plot_response_bar]
|
|.................. | 50%
|
|................... | 52% [plot_with_bar]
|
|.................... | 55%
|
|..................... | 57% [plot_normal_qq]
|
|...................... | 60%
|
|....................... | 62% [plot_response_qq]
|
|........................ | 64%
|
|......................... | 67% [plot_by_qq]
|
|.......................... | 69%
|
|.......................... | 71% [correlation_analysis]
|
|........................... | 74%
|
|............................ | 76% [principal_component_analysis]
|
|............................. | 79%
|
|.............................. | 81% [bivariate_distribution_header]
|
|............................... | 83%
|
|................................ | 86% [plot_response_boxplot]
|
|................................. | 88%
|
|................................. | 90% [plot_by_boxplot]
|
|.................................. | 93%
|
|................................... | 95% [plot_response_scatterplot]
|
|.................................... | 98%
|
|.....................................| 100% [plot_by_scatterplot]
## output file: C:/Users/i7/Desktop/final son/report.knit.md
## "C:/Program Files/RStudio/resources/app/bin/quarto/bin/tools/pandoc" +RTS -K512m -RTS "C:\Users\i7\Desktop\FINALS~1\REPORT~1.MD" --to html4 --from markdown+autolink_bare_uris+tex_math_single_backslash --output pandoc1fc451a77fa1.html --lua-filter "C:\Users\i7\AppData\Local\R\cache\R\renv\cache\v5\R-4.3\x86_64-w64-mingw32\rmarkdown\2.25\d65e35823c817f09f4de424fcdfa812a\rmarkdown\rmarkdown\lua\pagebreak.lua" --lua-filter "C:\Users\i7\AppData\Local\R\cache\R\renv\cache\v5\R-4.3\x86_64-w64-mingw32\rmarkdown\2.25\d65e35823c817f09f4de424fcdfa812a\rmarkdown\rmarkdown\lua\latex-div.lua" --embed-resources --standalone --variable bs3=TRUE --section-divs --table-of-contents --toc-depth 6 --template "C:\Users\i7\AppData\Local\R\cache\R\renv\cache\v5\R-4.3\x86_64-w64-mingw32\rmarkdown\2.25\d65e35823c817f09f4de424fcdfa812a\rmarkdown\rmd\h\default.html" --no-highlight --variable highlightjs=1 --variable theme=yeti --mathjax --variable "mathjax-url=https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" --include-in-header "C:\Users\i7\AppData\Local\Temp\RtmpYDBuod\rmarkdown-str1fc4665d6a85.html"
##
## Output created: report.html
train [c("ailenum","ailesira")] <- str_split_fixed(train$PassengerId, "_", 2)
Bu kodun amacı, “train” veri çerçevesinde “PassengerId” sütunundaki her bir değeri “_” karakterine göre bölmektir.
test [c("ailenum","ailesira")] <- str_split_fixed(test$PassengerId, "_", 2)
train[c('deck','num','side')] <- str_split_fixed(train$Cabin, '/', 3)
train\(Cabin ifadesi, "train" adlı veri çerçevesindeki "Cabin" sütunundaki değerleri ifade eder. str_split_fixed(train\)Cabin, ‘/’, 3) ifadesi, “Cabin” sütunundaki her değeri ‘/’ karakterine göre üç parçaya bölmek. Bu üç parçayı yeni oluşturulan “deck”, “num”, ve “side” sütunlarına yerleştirir. <- operatörü, sağdaki değeri sol tarafındaki değişkenlere atar.
test[c('deck','num','side')] <- str_split_fixed(test$Cabin, '/', 3)
Bu işlem, ‘deck’ sütununa güvertenin adını, ‘num’ sütununa numarasını ve ‘side’ sütununa kenarını içeren bilgileri yerleştirmeyi amaçlar.
train[train == ''] <- NA
Bu kod, veri analizi veya modelleme süreçlerinde temizleme işlemleri sırasında kullanılır
test[test == ''] <- NA
train <- train %>% select(-Cabin)
Bu kod satırı “train” veri çerçevesinden “Cabin” sütununu çıkarır ve güncellenmiş veri çerçevesini “train” adlı değişkene atar.
test <- test %>% select(-Cabin)
unique(train$HomePlanet)
## [1] "Europa" "Earth" "Mars" NA
“HomePlanet” sütunundaki tekrar eden değerleri filtreleyerek sadece bir kez geçen değerleri getirir
unique(test$HomePlanet)
## [1] "Earth" "Europa" "Mars" NA
train$HomePlanet <- addNA(train$HomePlanet)
Bu kod satırı, eksik değerleri belirginleştirmek veya eksik değerlerle çalışmak için bir veri seti hazırlama aşaması iöin kullanılır
test$HomePlanet <- addNA(test$HomePlanet)
levels(train$HomePlanet )
## [1] "Earth" "Europa" "Mars" NA
Bu kod satırı, “train$HomePlanet” faktör değişkenin seviyelerini elde etmek için kullanılır.
levels(test$HomePlanet )
## [1] "Earth" "Europa" "Mars" NA
levels(train$HomePlanet)[is.na(levels(train$HomePlanet))] <- "NA"
Bu kod,eksik değerlere özel bir kategori atamak veya eksik değerleri belirginleştirmek amacıyla kullanılılır
levels(test$HomePlanet)[is.na(levels(test$HomePlanet))] <- "NA"
levels(train$HomePlanet)
## [1] "Earth" "Europa" "Mars" "NA"
Bu kod satırı,tüm değişkenlere ait detaylı istatistiksel özetleri elde etmek için bu fonksiyonunu kullanır.
train <- train %>%
group_by(HomePlanet,Destination) %>%
mutate_at(vars(Age) ,~replace_na(., mean(., na.rm = TRUE)))
daha güvenilir istatistiksel analizler yapmak ve eksik verilerle daha etkili bir şekilde başa çıkmak için kullanılan bir yöntemdir.
test <- test %>%
group_by(HomePlanet,Destination) %>%
mutate_at(vars(Age) ,~replace_na(., mean(., na.rm = TRUE)))
train$CryoSleep <- addNA(train$CryoSleep)
Bu tür bir işlem, eksik değerleri daha açık bir şekilde görmek veya belirli bir işleme tabi tutmak için kullanılır
test$CryoSleep <- addNA(test$CryoSleep)
levels(train$CryoSleep)[is.na(levels(train$CryoSleep))] <- "NA"
Bu işlem, “CryoSleep” faktör değişkenindeki eksik değerlere özel bir kategori atamak veya eksik değerleri belirginleştirmek amacıyla kullanılır.
levels(test$CryoSleep)[is.na(levels(test$CryoSleep))] <- "NA"
unique(train$Destination)
## [1] "TRAPPIST-1e" "PSO J318.5-22" "55 Cancri e" NA
bu işlem “Destination” değişkeninde bulunan farklı kategorik değerleri listeleyerek, bu değişkenin alabileceği farklı hedef değerlerini gösterir.
train$Destination <- addNA(train$Destination)
test$Destination <- addNA(test$Destination)
eksik değerleri daha açık bir şekilde görmek veya belirli bir işleme tabi tutmak amacıyla kullanılır
levels(train$Destination)[is.na(levels(train$Destination))] <- "NA"
levels(test$Destination)[is.na(levels(test$Destination))] <- "NA"
Bu işlem, “Destination” faktör değişkenindeki eksik değerlere özel bir kategori atamak veya eksik değerleri belirginleştirmek amacıyla kullanılır.
train$side <- addNA(train$side)
test$side <- addNA(test$side)
eksik değerleri daha açık bir şekilde görmek veya belirli bir işleme tabi tutmak amacıyla kullanılır
levels(train$side)[is.na(levels(train$side))] <- "NA"
levels(test$side)[is.na(levels(test$side))] <- "NA"
Bu işlem, “side” faktör değişkenindeki eksik değerlere özel bir kategori atamak veya eksik değerleri belirginleştirmek amacıyla kullanılır.
train$VIP <- addNA(train$VIP)
kod satırı, “train” veri çerçevesindeki “VIP” adlı bir değişkenin içindeki eksik değerlere (NA) “NA” eklemek için kullanılır.
test$VIP <- addNA(test$VIP)
levels(train$VIP )[is.na(levels(train$VIP))] <- "NA"
Bu işlem, “VIP” faktör değişkenindeki eksik değerlere özel bir kategori atamak veya eksik değerleri belirginleştirmek amacıyla kullanılabilir
levels(test$VIP )[is.na(levels(test$VIP))] <- "NA"
hist(train$FoodCourt)
Histogram, bir değişkenin genel dağılım şeklini, merkezi eğilimini,
yayılımını ve olası aykırı değerleri görmek için kullanılır.
train <- train %>% mutate(FoodCourt = coalesce(FoodCourt, 0))
eksik değerlere özel bir değer atamak veya eksik değerleri belirli bir değerle doldurmak amacıyla kullanılır.
test <- test %>% mutate(FoodCourt = coalesce(FoodCourt, 0))
train$RoomService <- addNA(train$RoomService)
test$RoomService <- addNA(test$RoomService)
train$ShoppingMall <- addNA(train$ShoppingMall)
test$ShoppingMall <- addNA(test$ShoppingMall)
train$FoodCourt <- addNA(train$FoodCourt)
test$FoodCourt <- addNA(test$FoodCourt)
train$Spa <- addNA(train$Spa)
test$Spa <- addNA(test$Spa)
train$VRDeck <- addNA(train$VRDeck)
test$VRDeck <- addNA(test$VRDeck)
train$deck <- addNA(train$deck)
test$deck <- addNA(test$deck)
train <- train %>% select(-Name)
test <- test %>% select(-Name)
train <- train %>% select(-num)
test <- test %>% select(-num)
train$aile<-ifelse(duplicated(train$ailenum)| duplicated(train$ailenum, fromLast = TRUE),1,0)
test$aile<-ifelse(duplicated(test$ailenum)| duplicated(test$ailenum, fromLast = TRUE),1,0)
train%>%describe_all()
## # A tibble: 17 × 8
## variable type na na_pct unique min mean max
## <chr> <chr> <int> <dbl> <int> <dbl> <dbl> <dbl>
## 1 PassengerId chr 0 0 8693 NA NA NA
## 2 HomePlanet fct 0 0 4 NA NA NA
## 3 CryoSleep fct 0 0 3 NA NA NA
## 4 Destination fct 0 0 4 NA NA NA
## 5 Age dbl 0 0 91 0 28.8 79
## 6 VIP fct 0 0 3 NA NA NA
## 7 RoomService fct 0 0 1274 NA NA NA
## 8 FoodCourt fct 0 0 1507 NA NA NA
## 9 ShoppingMall fct 0 0 1116 NA NA NA
## 10 Spa fct 0 0 1328 NA NA NA
## 11 VRDeck fct 0 0 1307 NA NA NA
## 12 Transported lgl 0 0 2 0 0.5 1
## 13 ailenum chr 0 0 6217 NA NA NA
## 14 ailesira chr 0 0 8 NA NA NA
## 15 deck fct 0 0 9 NA NA NA
## 16 side fct 0 0 3 NA NA NA
## 17 aile dbl 0 0 2 0 0.45 1
test%>%describe_all()
## # A tibble: 16 × 8
## variable type na na_pct unique min mean max
## <chr> <chr> <int> <dbl> <int> <dbl> <dbl> <dbl>
## 1 PassengerId chr 0 0 4277 NA NA NA
## 2 HomePlanet fct 0 0 4 NA NA NA
## 3 CryoSleep fct 0 0 3 NA NA NA
## 4 Destination fct 0 0 4 NA NA NA
## 5 Age dbl 0 0 91 0 28.7 79
## 6 VIP fct 0 0 3 NA NA NA
## 7 RoomService fct 0 0 843 NA NA NA
## 8 FoodCourt fct 0 0 902 NA NA NA
## 9 ShoppingMall fct 0 0 716 NA NA NA
## 10 Spa fct 0 0 834 NA NA NA
## 11 VRDeck fct 0 0 797 NA NA NA
## 12 ailenum chr 0 0 3063 NA NA NA
## 13 ailesira chr 0 0 8 NA NA NA
## 14 deck fct 0 0 9 NA NA NA
## 15 side fct 0 0 3 NA NA NA
## 16 aile dbl 0 0 2 0 0.45 1
##logistik regresyon
train_set <-train [2:17]
test_set <-test [2:16]
create_report(train)
##
##
## processing file: report.rmd
##
|
| | 0%
|
|. | 2%
|
|.. | 5% [global_options]
|
|... | 7%
|
|.... | 10% [introduce]
|
|.... | 12%
|
|..... | 14% [plot_intro]
|
|...... | 17%
|
|....... | 19% [data_structure]
|
|........ | 21%
|
|......... | 24% [missing_profile]
|
|.......... | 26%
|
|........... | 29% [univariate_distribution_header]
|
|........... | 31%
|
|............ | 33% [plot_histogram]
|
|............. | 36%
|
|.............. | 38% [plot_density]
|
|............... | 40%
|
|................ | 43% [plot_frequency_bar]
|
|................. | 45%
|
|.................. | 48% [plot_response_bar]
|
|.................. | 50%
|
|................... | 52% [plot_with_bar]
|
|.................... | 55%
|
|..................... | 57% [plot_normal_qq]
|
|...................... | 60%
|
|....................... | 62% [plot_response_qq]
|
|........................ | 64%
|
|......................... | 67% [plot_by_qq]
|
|.......................... | 69%
|
|.......................... | 71% [correlation_analysis]
|
|........................... | 74%
|
|............................ | 76% [principal_component_analysis]
|
|............................. | 79%
|
|.............................. | 81% [bivariate_distribution_header]
|
|............................... | 83%
|
|................................ | 86% [plot_response_boxplot]
|
|................................. | 88%
|
|................................. | 90% [plot_by_boxplot]
|
|.................................. | 93%
|
|................................... | 95% [plot_response_scatterplot]
|
|.................................... | 98%
|
|.....................................| 100% [plot_by_scatterplot]
## output file: C:/Users/i7/Desktop/final son/report.knit.md
## "C:/Program Files/RStudio/resources/app/bin/quarto/bin/tools/pandoc" +RTS -K512m -RTS "C:\Users\i7\Desktop\FINALS~1\REPORT~1.MD" --to html4 --from markdown+autolink_bare_uris+tex_math_single_backslash --output pandoc1fc446626eb6.html --lua-filter "C:\Users\i7\AppData\Local\R\cache\R\renv\cache\v5\R-4.3\x86_64-w64-mingw32\rmarkdown\2.25\d65e35823c817f09f4de424fcdfa812a\rmarkdown\rmarkdown\lua\pagebreak.lua" --lua-filter "C:\Users\i7\AppData\Local\R\cache\R\renv\cache\v5\R-4.3\x86_64-w64-mingw32\rmarkdown\2.25\d65e35823c817f09f4de424fcdfa812a\rmarkdown\rmarkdown\lua\latex-div.lua" --embed-resources --standalone --variable bs3=TRUE --section-divs --table-of-contents --toc-depth 6 --template "C:\Users\i7\AppData\Local\R\cache\R\renv\cache\v5\R-4.3\x86_64-w64-mingw32\rmarkdown\2.25\d65e35823c817f09f4de424fcdfa812a\rmarkdown\rmd\h\default.html" --no-highlight --variable highlightjs=1 --variable theme=yeti --mathjax --variable "mathjax-url=https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" --include-in-header "C:\Users\i7\AppData\Local\Temp\RtmpYDBuod\rmarkdown-str1fc4f6c379f.html"
##
## Output created: report.html