Skip to content

Instantly share code, notes, and snippets.

View pr2tik1's full-sized avatar
🏞️
WFH

Pratik Kumar pr2tik1

🏞️
WFH
View GitHub Profile
❗️ Closed issue #1 in veerkalburgi/veerkalburgi.github.io
❗️ Opened issue #1 in veerkalburgi/veerkalburgi.github.io
❗️ Opened issue #4 in orhanarifoglu/orhanarifoglu.github.io
🎉 Merged PR #2 in pr2tik1/activity-box
import tensorflow as tf
import tensorflow_datasets as tfds
from tensorflow import keras
import numpy as np
import os
import urllib.request
#Names of 10 Classes:
class_names = ['cloud', 'sun', 'pants', 'umbrella', 'table', 'ladder',
'eyeglasses', 'clock', 'scissors', 'cup']
import ast
from PIL import Image
import torchvision.transforms as transforms
from torch.autograd import Variable
import torchvision.models as models
from torch import __version__
resnet18 = models.resnet18(pretrained=True)
alexnet = models.alexnet(pretrained=True)
vgg16 = models.vgg16(pretrained=True)
<img src="https://github.com/pr2tik1/pr2tik1/blob/master/IMAGE-NAME">
### Hi 👋
I am recent engineering graduate looking for opportunities and collabaration in projects related to data science and deep learning.
- 🔭 I’m currently working on image classification (also, I am brushing up my data structures and algorithms skills regularly).
- 🌱 I’m currently learning Computer Vision and Deep Learning techniques using PyTorch.
- 🤝 I’m looking to collaborate on data science and deep learning projects.
![YOUR github stats](https://github-readme-stats.vercel.app/api?username=USERNAME)
We can make this file beautiful and searchable if this error is corrected: It looks like row 7 should actually have 13 columns, instead of 10. in line 6.
ctryname cowcode2 politycode un_region_name un_continent_name ehead leaderspellreg democracy regime start_year duration observed
1 Afghanistan 700 700.0 Southern Asia Asia Mohammad Zahir Shah Mohammad Zahir Shah.Afghanistan.1946.1952.Monarchy Non-democracy Monarchy 1946 7 1
2 Afghanistan 700 700.0 Southern Asia Asia Sardar Mohammad Daoud Sardar Mohammad Daoud.Afghanistan.1953.1962.Civilian Dict Non-democracy Civilian Dict 1953 10 1
3 Afghanistan 700 700.0 Southern Asia Asia Mohammad Zahir Shah Mohammad Zahir Shah.Afghanistan.1963.1972.Monarchy Non-democracy Monarchy 1963 10 1
4 Afghanistan 700 700.0 Southern Asia Asia Sardar Mohammad Daoud Sardar Mohammad Daoud.Afghanistan.1973.1977.Civilian Dict Non-democracy Civilian Dict 1973 5 0
5 Afghanistan 700 700.0 Southern Asia Asia Nur Mohammad Taraki Nur Mohammad Taraki.Afghanistan.1978.1978.Civilian Dict Non-democracy Civilian Dict 1978 1 0
6 Afghanistan 700 700.0 Southern Asia Asia Babrak Karmal Babrak Karmal.Afghanistan.1979.1984.Civilian Dict Non-democracy Civ
time Died group
1 485 0 1
2 526 1 2
3 588 1 2
4 997 0 1
5 426 1 1
6 625 0 1
7 564 0 1
8 543 0 1
9 523 0 1
def fixing_skewness(self):
"""
Function takes in a dataframe and return fixed skewed dataframe
"""
## Getting all the data that are not of "object" type.
numeric = self.data.dtypes[self.data.dtypes != "object"].index
# Check the skew of all numerical features
skewed_feats = self.data[numeric].apply(lambda x: skew(x)).sort_values(ascending=False)
high_skew = skewed_feats[abs(skewed_feats) > 0.5]
def find_non_rare_labels(self, variable, tolerance):
'''
Function to check cardinality of a feature.
Args: Dataframe,
Feature - Numerical Features,
Tolerance - Threshold of number of values.
Output: List of unique values of the feature.
'''
temp = self.data.groupby([variable])[variable].count() / len(self.data)
non_rare = [x for x in temp.loc[temp>tolerance].index.values]
def Imputation(self, var ,stats=False):
'''
Function to Impute data using sklearn Imputer
Input : Dataframe, variable(continuous/categorical)
Output : None
'''
if var==self.continuous:
imputer= SimpleImputer(strategy='median')
if var==self.categorical:
imputer = SimpleImputer(strategy='most_frequent')
def plot_missing(self,png=False):
"""
Function to plot Missing data in the dataframe
Input: dataframe
Output: Bar-Plot
"""
missing_data = self.data.isnull().sum()
missing_df = pd.DataFrame(missing_data.drop(missing_data[missing_data == 0].index).sort_values(ascending=False),
columns = ['values'])
fig = px.bar(data_frame = missing_df, x = missing_df.index, y = missing_df.values, text =missing_df.values,