This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##GRADIENT DESCENT ALGORITHM FOR ONE VARIABLE REGRESSION ANALYSIS | |
#Data is from an online course taught by Andrew Ng of Stanford University | |
#provided by Coursea | |
#https://github.com/ahawker/machine-learning-coursera | |
############## Cevrimici (online) bir kaynaktan veri seti okutma ############## | |
URL_subs <-"https://goo.gl/zEVbcU" | |
data <- read.table(URL_subs, header=FALSE, sep=",") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Fonksiyonu yaratalim | |
WilcoxonSignedRankTest <- function(x,y){ | |
diff <- c(x - y) #her gozlem ikilisi arasindaki farki tutan bir vektor hesaplayalim | |
diff.rank <- rank(abs(diff)) #farklarin mutlak degerini alarak siralayalim ve siralarini kaydedelim. | |
diff.rank.sign <- diff.rank * sign(diff) #her sira numarasini, karsilik gelen isaret ile etiketleyelim. | |
ranks.pos <- sum(diff.rank.sign[diff.rank.sign > 0]) #pozitif degerli siralamalarin sira degerlerini toplayalim. | |
ranks.neg <- -sum(diff.rank.sign[diff.rank.sign < 0]) #negatif degerli siralamalarin sira degerlerini toplayalim. | |
result<- c(ranks.pos,ranks.neg) | |
print(result) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
housing <- read.csv("https://goo.gl/eYbv9F", | |
header = TRUE, | |
sep = "," ) | |
str(housing) | |
#'data.frame': 47 obs. of 3 variables: | |
# $ area : int 2104 1600 2400 1416 3000 1985 1534 1427 1380 1494 ... | |
# $ bedrooms: int 3 3 3 2 4 4 3 3 3 3 ... | |
# $ price : int 399900 329900 369000 232000 539900 299900 314900 198999 212000 242500 ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
normalized <- function(x) ( x - mean(x) ) / sd(x) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GradientDescent <- function(data, alpha, iteration, epsilon){ | |
data <- matrix(unlist(data), ncol=ncol(data), byrow=FALSE) | |
# bagimli degiskeni ve bagimsiz degiskenleri ayiralim. | |
#Veridaki en son kolon, bagimli degiskene ait olmalidir. | |
independent.variable<- data[,1:ncol(data)-1] | |
dependent.variable<- data[,ncol(data)] | |
# girdi degiskenlerine z-değeri normalleştirmesi uygulayalim. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Veriyi okutma | |
housing <- read.csv("https://goo.gl/eYbv9F", | |
header = TRUE, | |
sep = "," ) | |
#Fonksyonu calistirma | |
results <- GradientDescent( data = housing, alpha = 0.05, | |
iteration = 500, epsilon = 0.001) | |
#Analiz sonuclari |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
housing <- read.csv("https://goo.gl/eYbv9F", | |
header = TRUE, | |
sep = "," ) | |
normalized <- apply(housing[ , -3 ], 2, scale) | |
normalized_data <- data.frame(cbind(normalized, price = housing$price)) | |
model <- lm( price ~ ., data = normalized_data) | |
model | |
# | |
#Call: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Her iterasyon sonrasi elde edilen maliyet fonksiyonu degerlerini cizdirelim. | |
costs_df <- data.frame( iteration = 1:nrow(results$costs), | |
costs = results$costs / 1e+8 ) | |
plot(1:nrow(results$costs),costs_df$costs,xlab = "Iteration", ylab = "Cost") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
URL_subs <-"https://goo.gl/zEVbcU" | |
data <- read.table(URL_subs, header=FALSE, sep=",") | |
model <- lm(data$V2~ ., data = data) | |
model | |
#Call: | |
# lm(formula = data$V2 ~ ., data = data) | |
# | |
#Coefficients: | |
# (Intercept) V1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import print_function, division | |
import numpy as np | |
import tensorflow as tf | |
import matplotlib.pyplot as plt | |
num_epochs = 100 | |
total_series_length = 50000 | |
truncated_backprop_length = 15 | |
state_size = 4 | |
num_classes = 2 |
OlderNewer