Skip to content

Instantly share code, notes, and snippets.

View therealnaveenkamal's full-sized avatar
🎯
Focusing

Naveenraj Kamalakannan therealnaveenkamal

🎯
Focusing
View GitHub Profile
@therealnaveenkamal
therealnaveenkamal / stockvisualizer.py
Last active April 28, 2021 15:44
This Code Snippet helps us to visualize the stock price over the given time period
import matplotlib.pyplot as plt
from pandas_datareader import data
df = data.DataReader("RELIANCE.NS",
data_source = "yahoo",
start = "2016-04-28",
end = "2021-03-28")
plt.style.use("fivethirtyeight")
plt.figure(figsize=(15,10))
@therealnaveenkamal
therealnaveenkamal / dcp1.py
Created April 28, 2021 16:01
Daily Coding Problem #1
def checkFunc(k, input_nums):
for i in range(len(input_nums)):
for j in range(i+1,len(input_nums)):
if(input_nums[i] + input_nums[j] == k):
return True
return False
input_nums = list(map(int, input().split(" ")))
k = int(input())
print(checkFunc(k, input_nums))
@therealnaveenkamal
therealnaveenkamal / stockvol_line.py
Last active April 29, 2021 03:56
The Volume Plot that shows the period of alertness and large trades. Significantly, Volume can turn out as an essential feature
import seaborn as sns
import matplotlib.pyplot as plt
from pandas_datareader import data
df = data.DataReader("RELIANCE.NS",
data_source = "yahoo",
start = "2010-04-28",
end = "2021-03-28")
plt.style.use("fivethirtyeight")
@therealnaveenkamal
therealnaveenkamal / edastock.py
Created April 29, 2021 05:45
Exploratory Data Analysis of Time Series Stock Data
from pandas_datareader import data
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
df = data.DataReader("RELIANCE.NS",
data_source = "yahoo",
start = "2010-01-28",
end = "2020-12-28")
@therealnaveenkamal
therealnaveenkamal / trend_seasonality.py
Last active April 29, 2021 07:21
This Code Snippet Plots the Trend and the Seasonality of the Time Series data
from pandas_datareader import data
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
df = data.DataReader("RELIANCE.NS",
data_source = "yahoo",
start = "2010-01-28",
end = "2020-12-28")
@therealnaveenkamal
therealnaveenkamal / timeseries_decomp.py
Created April 29, 2021 10:51
This Code Snippet is used to decompose Time Series data into its respective components.
from pandas_datareader import data
import statsmodels.api as sm
from pylab import rcParams
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
df = data.DataReader("RELIANCE.NS",
data_source = "yahoo",
@therealnaveenkamal
therealnaveenkamal / cxr_multiclassclassification.py
Last active July 22, 2021 05:37
Packages required for Chest X-Ray based Multi-Class Disease Classification using DenseNet121 - Transfer Learning Approach
import os
import cv2
import random
import numpy as np
import pandas as pd
import seaborn as sns
import tensorflow as tf
import matplotlib.pyplot as plt
from keras import backend as K
@therealnaveenkamal
therealnaveenkamal / cxr_multiclassclassification_datasetsplit.py
Created July 20, 2021 05:13
This code manually splits up the dataset into train, validation and test with 20:4:1 as their respective ratios.
dataframe = pd.read_csv("Data_Entry_2017_v2020.csv")
#Enumerating all column names
columns = ["Image"]
for i in dataframe["Finding Labels"].values:
for j in i.split("|"):
if j not in columns:
columns.append(j)
labels = columns.copy()
labels.remove("Image")
@therealnaveenkamal
therealnaveenkamal / cxr_multiclassclassification_overlap.py
Created July 20, 2021 06:08
This code checks for the overlap of patients between train, validation and test dataset and removes the respective patients from their datasets.
def isOverlap(s1, s2):
total = set(s1).intersection(set(s2))
return [len(total), total]
def overlapcheck(trainset, valset, testset):
patid_train = []
patid_val = []
patid_test = []
for name in trainset['Image'].values:
patid_train.append(int(name.split("_")[0]))
@therealnaveenkamal
therealnaveenkamal / cxr_sample_image_analysis.py
Created July 20, 2021 06:40
This code takes in a random sample image, plots a histplot and analyzes the pixel intensities
num = np.random.randint(trainset.shape[0])
sample = plt.imread(os.path.join(img_dir,trainset.iloc[[num]]["Image"].values[0]))
plt.figure(figsize=(15, 15))
plt.title(dataframe[dataframe["Image Index"] == trainset.iloc[[num]]["Image"].values[0]].values[0][1])
plt.imshow(sample, cmap = 'gray')
plt.colorbar()
trainset.iloc[[num]]
print("Maximum Pixel Value: ", sample.max())
print("Minimum Pixel Value: ", sample.min())