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
# # 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', 'ARDAHAN', 'ARTVIN', 'AYDIN', 'BALIKESIR', 'BARTIN', 'BATMAN', 'BAYBURT', 'BILECIK', 'BINGOL', ' |
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
## MULTICLASS CROSS ENTROPY | |
import tensorflow as tf | |
import numpy as np | |
from sklearn.metrics import log_loss | |
#4 observations and 4 classes | |
y_true = [4,4,3,1] #Hard classes | |
y_true_onehot = [[0,0,0,1], [0,0,0,1], [0,0,1,0], [1,0,0,0]] #one_hot encoding | |
y_pred = [[0.2, 0.2, 0.2, 0.2], [0.6, 0.7, 0.1, 0.2], [0.3, 0.9, 0.1, 0.1], [0.1, 0.5, 0.7, 0.4]] | |
y_pred_softmax = [[0.25, 0.25, 0.25, 0.25], [0.29568115, 0.3267782, 0.17933969, 0.198201], [0.22423635, 0.40858525, 0.18358919, 0.18358919], [0.17655984, 0.26339632, 0.32171297, 0.23833084]] |
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 numpy as np | |
import tensorflow as tf | |
from sklearn.datasets import fetch_california_housing | |
from sklearn.preprocessing import StandardScaler | |
import math | |
housing = fetch_california_housing() | |
print(type(housing['data'])) | |
print(type(housing['target'])) |
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
## BINARY CLASS CROSS ENTROPY | |
import tensorflow as tf | |
import numpy as np | |
from sklearn.metrics import log_loss | |
#4 observations and 2 classes | |
y_true = [0,0,0,1] #Hard classes | |
y_pred = [0.2, 0.2, 0.2, 0.2] | |
y_pred_softmax = [0.54983395, 0.54983395, 0.54983395, 0.54983395] #soft predictions | |
#BY HAND |
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] |
NewerOlder