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
# -*- coding: utf-8 -*- | |
""" | |
@author: satyam.kumar | |
""" | |
''' | |
Import necessary packages | |
''' |
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 pandas as pd | |
import os | |
import gc | |
import re | |
from nltk.corpus import stopwords | |
from nltk.stem import PorterStemmer | |
from bs4 import BeautifulSoup | |
def preprocess(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
#Install the below libaries before importing | |
import pandas as pd | |
from pandas_profiling import ProfileReport | |
#EDA using pandas-profiling | |
profile = ProfileReport(pd.read_csv('titanic.csv'), explorative=True) | |
#Saving results to a HTML file | |
profile.to_file("output.html") |
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 pandas as pd | |
from sklearn.preprocessing import LabelEncoder | |
from sklearn.preprocessing import OrdinalEncoder | |
from category_encoders import BinaryEncoder | |
from category_encoders import TargetEncoder | |
#Label Encoder | |
le = LabelEncoder() | |
df['columnName'] = le.fit_transform(df['columnName']) |
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 pandas as pd | |
# load height-weight dataset downloaded from kaggle | |
data = pd.read_csv("weight-height.csv") | |
#equal width binning | |
data["ewb"] = pd.cut(data["Height"], bins=10) | |
#equal frequency binning | |
data["efb"] = pd.qcut(data["Height"], q=10) |
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 pandas as pd | |
pip install datawig | |
import datawig | |
data = pd.read_csv("train.csv") | |
df_train, df_test = datawig.utils.random_split(data) | |
#Initialize a SimpleImputer model | |
imputer = datawig.SimpleImputer( |