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
price_data = resources.groupby('id').agg({'price':'sum', 'quantity':'sum'}).reset_index() | |
# join two dataframes in python: | |
data = pd.merge(data, price_data, on='id', how='left') |
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['school_state'] = data['school_state'].str.lower() |
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(f'Number of null values:{data["teacher_prefix"].isnull().sum()}') |
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
sns.countplot(data['project_is_approved']) | |
plt.show() |
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["teacher_prefix"] = data["teacher_prefix"].fillna('Mrs.') | |
data["teacher_prefix"] = data["teacher_prefix"].str.replace('.','') | |
data["teacher_prefix"] = data["teacher_prefix"].str.lower() |
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 clean_pro(col): | |
col = col.str.replace('The', '') | |
col = col.str.replace(' ','') | |
col = col.str.replace('&','_') | |
col = col.str.replace(',','_') | |
col = col.str.lower() | |
return col | |
data['project_subject_subcategories'] = clean_pro(data['project_subject_subcategories']) |
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['project_grade_category'] = data['project_grade_category'].str.replace(' ','_') | |
data['project_grade_category'] = data['project_grade_category'].str.replace('-','_') | |
data['project_grade_category'] = data['project_grade_category'].str.lower() | |
data['project_grade_category'].value_counts() |
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 warnings | |
warnings.filterwarnings("ignore") | |
import shutil, time | |
import torch | |
from torch.utils.tensorboard import SummaryWriter | |
import torch.nn.functional as F | |
import torch.nn as nn | |
from torch.utils.data import TensorDataset, DataLoader | |
from collections import Counter,defaultdict |
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 = pd.read_csv('train.csv') | |
resources = pd.read_csv('resources.csv') | |
print(f'Train file shape: {data.shape}') | |
print(f'Resource file shape: {resources.shape}') |
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
# Utility functions | |
# function to load the classes | |
def load_classes(class_file): | |
fp = open(class_file, "r") | |
names = fp.read().split("\n")[:-1] | |
return names | |
# function converting images from opencv format to torch format | |
def preprocess_image(img, inp_dim): |