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
import datetime | |
holidays = {datetime.date(2020, 1, 1): 'Yeni Yıl', | |
datetime.date(2020, 4, 23): "Ulusal Egemenlik ve Çocuk Bayramı", | |
datetime.date(2020, 5, 1): 'İşçi ve Emekçiler Bayramı', | |
datetime.date(2020, 5, 19): "Atatürk'ü Anma, Gençlik ve Spor Bayramı", | |
datetime.date(2020, 5, 23): 'Ramazan Bayramı Arife Günü', | |
datetime.date(2020, 5, 24): 'Ramazan Bayramı', | |
datetime.date(2020, 5, 25): 'Ramazan Bayramı ', | |
datetime.date(2020, 5, 26): 'Ramazan Bayramı ', |
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
import re | |
def tr_upper(self): | |
self = re.sub(r"i", "İ", self) | |
self = re.sub(r"ı", "I", self) | |
self = re.sub(r"ç", "Ç", self) | |
self = re.sub(r"ş", "Ş", self) | |
self = re.sub(r"ü", "Ü", self) | |
self = re.sub(r"ğ", "Ğ", self) | |
self = re.sub(r"â", "a", self) |
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
def seed_everything(seed: int): | |
import random, os | |
import numpy as np | |
import torch | |
random.seed(seed) | |
os.environ['PYTHONHASHSEED'] = str(seed) | |
np.random.seed(seed) | |
torch.manual_seed(seed) | |
torch.cuda.manual_seed(seed) |
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
contractions_dict = { "ain’t": "are not", "’s":" is", "aren’t": "are not", "can’t": "cannot", "can’t’ve": "cannot have", "‘cause": "because", | |
"could’ve": "could have", "couldn’t": "could not", "couldn’t’ve": "could not have", "didn’t": "did not", "doesn’t": "does not", | |
"don’t": "do not", "hadn’t": "had not", "hadn’t’ve": "had not have", "hasn’t": "has not", "haven’t": "have not", "he’d": "he would", | |
"he’d’ve": "he would have", "he’ll": "he will", "he’ll’ve": "he will have", "how’d": "how did", "how’d’y": "how do you", "how’ll": "how will", | |
"I’d": "I would", "I’d’ve": "I would have", "I’ll": "I will", "I’ll’ve": "I will have", "I’m": "I am", "I’ve": "I have", "isn’t": "is not", | |
"it’d": "it would", "it’d’ve": "it would have", "it’ll": "it will", "it’ll’ve": "it will have", "let’s": "let us", "ma’am": "madam", | |
"mayn’t": "may not", "might’ve": "might have", "mightn’t": "might not", "m |
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 unicode_tr import unicode_tr | |
df['cities'] = df['cities'].apply(unicode_tr.capitalize) | |
## Turkish Cities | |
cities = ["Adana","Adiyaman","Afyon","Agri","Aksaray","Amasya","Ankara","Antalya","Ardahan","Artvin","Aydin","Balikesir","Bartin","Batman","Bayburt","Bilecik","Bingol","Bitlis","Bolu","Burdur","Bursa","Canakkale","Cankiri","Corum","Denizli","Diyarbakir","Duzce","Edirne","Elazig","Erzincan","Erzurum","Eskisehir","Gaziantep","Giresun","Gumushane","Hakkari","Hatay","Igdir","Isparta","Istanbul","Izmir","Kahramanmaras","Karabuk","Karaman","Kars","Kastamonu","Kayseri","Kilis","Kirikkale","Kirklareli","Kirsehir","Kocaeli","Konya","Kutahya","Malatya","Manisa","Mardin","Mersin","Mugla","Mus","Nevsehir","Nigde","Ordu","Osmaniye","Rize","Sakarya","Samsun","Sanliurfa","Siirt","Sinop","Sirnak","Sivas","Tekirdag","Tokat","Trabzon","Tunceli","Usak","Van","Yalova","Yozgat","Zonguldak"] | |
# # Turkish Cities Uppercase | |
cities_upper = ['ADANA', 'ADIYAMAN', 'AFYON', 'AGRI', 'AKSARAY', 'AMASYA', 'ANKARA', 'ANTALYA', 'ARDAH |
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
file_name multi_hot_encoding Labels Categories | |
---------------------------------------------------------------------------------------------------- | |
0.png [1, 0, 0, 0, 0] [1] [Desert] | |
10.png [1, 1, 0, 0, 1] [1, 2] [Desert, Mountains] | |
47.png [1, 0, 0, 1, 1] [1, 4, 5] [Desert, Sunset, Trees] |
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
import matplotlib.pyplot as plt | |
import numpy as np | |
from math import ceil | |
def multi_convolution2d(input, filter, strides=(1, 1), padding='SAME'): | |
#This is for multiple filter | |
if not len(filter.shape) == 4: | |
raise ValueError("The size of filter should be (filter_height, filter_width, filter_depth, number_of_filters)") | |
if not len(input.shape) == 3: |
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
import matplotlib.pyplot as plt | |
import numpy as np | |
from math import ceil | |
def convolution2d(input, filter, bias=0, strides=(1, 1), padding='SAME'): | |
#This is only for using one filter | |
if not len(filter.shape) == 3: | |
raise ValueError("The size of the filter should be (filter_height, filter_width, filter_depth)") | |
if not len(input.shape) == 3: |
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
reset_graph() | |
n_epochs = 1000 | |
learning_rate = 0.01 | |
epsilon = 1e-7 | |
X = tf.constant(inputs, dtype = tf.float32, name = "x") | |
y = tf.constant(output, dtype = tf.float32, name = "y") | |
theta = tf.Variable(tf.random_uniform([n,1], -1.0, 1.0), name ="theta") | |
logits = tf.matmul(X, theta, name="logits") | |
#predictions = 1/(1+ tf.exp(-logits)) |
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
reset_graph() | |
n_epochs = 1000 | |
learning_rate = 0.01 | |
X = tf.constant(inputs, dtype = tf.float32, name = "x") | |
y = tf.constant(output, dtype = tf.float32, name = "y") | |
theta = tf.Variable(tf.random_uniform([n,1], -1.0, 1.0), name ="theta") | |
logits = tf.matmul(X, theta, name="logits") | |
#predictions = 1/(1+ tf.exp(-logits)) | |
predictions = tf.sigmoid(logits) |
NewerOlder