-
Notifications
You must be signed in to change notification settings - Fork 2
/
yapay-sinir-aglari.R
121 lines (85 loc) · 2.69 KB
/
yapay-sinir-aglari.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# YAPAY SİNİR AĞLARI
### İlk önce bütün girdileri temizleyelim
rm(list = ls())
## Kütüphaneler
library(caret)
library(tidyverse)
library(AppliedPredictiveModeling)
library(pls) #kismi en kucuk kareler ve pcr icin
library(elasticnet)
library(broom) #tidy model icin
library(glmnet)
library(MASS)
library(ISLR)
library(PerformanceAnalytics)
library(funModeling)
library(Matrix)
library(kernlab) #svm
library(e1071) #svm icin
library(rpart) #cart icin
library(pgmm) #olive data seti icin
library(dslabs)
library(rpart.plot) #rpart gorsel icin
library(partykit) #karar agaci gorseli icin
library(ipred) #bagging icin
library(randomForest)
library(gbm)
library(nnet)
library(neuralnet)
library(GGally)
library(NeuralNetTools) #garson fonksiyonu icin
library(FNN)
library(dplyr)
## Verisetimizi alalım
# http://archive.ics.uci.edu/ml/datasets/Yacht+Hydrodynamics
dff <- read_table(
file = 'http://archive.ics.uci.edu/ml/machine-learning-databases/00243/yacht_hydrodynamics.data',
col_names = c(
'longpos_cob',
'prismatic_coeff',
'len_disp_ratio',
'beam_draut_ratio',
'length_beam_ratio',
'froude_num',
'residuary_resist'
)
)
glimpse(dff)
summary(dff)
profiling_num(dff)
ggpairs(dff)
chart.Correlation(dff, histogram = T, pch=19)
olcekleme <- function(x) {
(x - min(x)) / (max(x)-min(x))
}
dff <- na.omit(dff)
sapply(dff, FUN = olcekleme)
train_indeks <- createDataPartition(dff$residuary_resist, p = 0.8, times = 1)
head(train_indeks)
train <- dff[train_indeks$Resample1, ]
test <- dff[-train_indeks$Resample1, ]
train_x <- train %>% dplyr::select(-residuary_resist)
train_y <- train %>% dplyr::select(residuary_resist)
test_x <- test %>% dplyr::select(-residuary_resist)
test_y <- test %>% dplyr::select(residuary_resist)
training <- data.frame(train_x, residuary_resist = train_y)
names(training)
# neuralnet kullanacağız ve bunun için formülün açıkça girilmesi gerekiyor.
ysa_formul <- residuary_resist ~ longpos_cob + prismatic_coeff + len_disp_ratio +
beam_draut_ratio + length_beam_ratio + froude_num
#bağımlı ve bağımsız değilkenlerle oluşan formülü yazdık
neuralnet(formula = ysa_formul, data = training)
plot(neuralnet(formula = ysa_formul, data = training, hidden = c(2,1), stepmax = 100),
rep="best")
mynn <-
nnet(
residuary_resist ~ longpos_cob + prismatic_coeff + len_disp_ratio + beam_draut_ratio + length_beam_ratio + froude_num,
data = training,
size = 2,
decay = 1.0e-5,
maxit = 5000
)
ysa_formul <- residuary_resist ~ longpos_cob + prismatic_coeff + len_disp_ratio + beam_draut_ratio + length_beam_ratio + froude_num
ysa1 <- neuralnet(ysa_formul, data = training)
plot(ysa1)
ysa1$result.matrix