This file contains hidden or 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
# mount gdrive | |
from google.colab import drive | |
drive.mount('/content/drive') | |
import pandas as pd | |
import matplotlib.pyplot as plt | |
import numpy as np | |
import warnings | |
warnings.filterwarnings("ignore") |
This file contains hidden or 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 tensorflow as tf | |
import torch | |
device_name = tf.test.gpu_device_name() | |
if device_name != '/device:GPU:0': | |
raise SystemError('GPU device not found') | |
print('Found GPU at: {}'.format(device_name)) | |
>>> torch.cuda.get_device_name(0) |
This file contains hidden or 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
print('average sentence length: ', df.Text.str.split().str.len().mean()) | |
print('stdev sentence length: ', df.Text.str.split().str.len().std()) |
This file contains hidden or 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 cv2 as cv | |
import glob | |
import matplotlib.pyplot as plt | |
path = "static/subfolder/*/*.jpg" | |
my_image_list = [] | |
for file in glob.glob(path): | |
file = cv.imread(file) # BGR |
This file contains hidden or 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
gpu_options = tf.compat.v1.GPUOptions(allow_growth=True) | |
session = tf.compat.v1.InteractiveSession( | |
config=tf.compat.v1.ConfigProto(gpu_options=gpu_options) | |
) |
This file contains hidden or 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
data['target_column'].value_counts().plot.bar(); |
This file contains hidden or 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 sampling_k_elements(group, k=3): | |
if len(group) < k: | |
return group | |
return group.sample(k) | |
balanced = df.groupby('class').apply(sampling_k_elements).reset_index(drop=True) |
This file contains hidden or 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 sampling_k_elements(group, k=3): | |
if len(group) < k: | |
return group | |
return group.sample(k) | |
balanced = df.groupby('class').apply(sampling_k_elements).reset_index(drop=True) |
This file contains hidden or 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 sys | |
# put your output data container | |
print(report) | |
original_stdout = sys.stdout | |
with open("classification_report.txt", "w") as f: | |
sys.stdout = f | |
# put your output data container again |
This file contains hidden or 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
# check if there is any null values | |
df.isnull().sum() | |
# remove null values in aany rows | |
df = df.dropna(how='any',axis=0) | |
# check again if there is any null values | |
df.isnull().sum() |