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
train.fillna(-999, inplace=True) | |
test.fillna(-999, inplace=True) |
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
gender_dict = {'F':0, 'M':1} | |
age_dict = {'0-17':0, '18-25':1, '26-35':2, '36-45':3, '46-50':4, '51-55':5, '55+':6} | |
city_dict = {'A':0, 'B':1, 'C':2} | |
stay_dict = {'0':0, '1':1, '2':2, '3':3, '4+':4} | |
train["Gender"] = train["Gender"].apply(lambda x: gender_dict[x]) | |
test["Gender"] = test["Gender"].apply(lambda x: gender_dict[x]) | |
train["Age"] = train["Age"].apply(lambda x: age_dict[x]) | |
test["Age"] = test["Age"].apply(lambda x: age_dict[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
submission = pd.DataFrame() | |
submission['User_ID'] = test['User_ID'] | |
submission['Product_ID'] = test['Product_ID'] |
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 missing_values_table(df): | |
mis_val = df.isnull().sum() | |
mis_val_percent = 100 * df.isnull().sum() / len(df) | |
mis_val_table = pd.concat([mis_val, mis_val_percent], axis=1) | |
mis_val_table_ren_columns = mis_val_table.rename( | |
columns = {0 : 'Missing Values', 1 : '% of Total Values'}) | |
mis_val_table_ren_columns = mis_val_table_ren_columns[ | |
mis_val_table_ren_columns.iloc[:,1] != 0].sort_values( | |
'% of Total Values', ascending=False).round(1) | |
print ("Your selected dataframe has " + str(df.shape[1]) + " columns.\n" |
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
train = pd.read_csv("train.csv") | |
test = pd.read_csv("test.csv") |
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
#importing libraries | |
import numpy as np | |
import pandas as pd | |
from math import * | |
from sklearn.model_selection import train_test_split | |
from sklearn.preprocessing import MinMaxScaler, LabelEncoder | |
from sklearn.tree import DecisionTreeRegressor | |
import xgboost as xgb | |
import matplotlib as plt | |
from sklearn.metrics import mean_squared_error, r2_score |
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
# Visualize | |
fig, axes = plt.subplots(1, len(faces)) | |
for face, ax in zip(faces, axes): | |
ax.imshow(face.permute(1, 2, 0).int().numpy()) | |
ax.axis('off') | |
fig.show() |
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
face = mtcnn(frame) |
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
mtcnn = MTCNN(margin=40,select_largest=False,keep_all=true) |
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
# Load a single image and display | |
frame = cv2.imread("1.jpg") | |
# mtcnn process the image in RGB and opencv reads in BGR. So converting that. | |
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB) | |
# generating image from array | |
frame = Image.fromarray(frame) | |
plt.figure(figsize=(12, 8)) | |
plt.imshow(frame) | |
plt.axis('off') |