Skip to content

Instantly share code, notes, and snippets.

View ishritam's full-sized avatar
🎯
Focusing

Shritam Kumar Mund ishritam

🎯
Focusing
View GitHub Profile
@ishritam
ishritam / iris dataset 1
Created October 9, 2019 06:53
importing libraries and load the dataset
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
import numpy as np
'''downlaod iris.csv from https://raw.githubusercontent.com/uiuc-cse/data-fa14/gh-pages/data/iris.csv'''
#Load Iris.csv into a pandas dataFrame.
iris = pd.read_csv("iris.csv")
@ishritam
ishritam / 2-D scatter plot
Created October 9, 2019 07:19
2-D scatter plot
#2-D scatter plot:
#ALWAYS understand the axis: labels and scale.
iris.plot(kind='scatter', x='sepal_length', y='sepal_width') ;
plt.show()
@ishritam
ishritam / 2-D Scatter plot with color
Created October 9, 2019 07:23
2-D Scatter plot with color
# 2-D Scatter plot with color-coding for each flower type/class.
# Here 'sns' corresponds to seaborn.
sns.set_style("whitegrid");
sns.FacetGrid(iris, hue="species", size=4) \
.map(plt.scatter, "sepal_length", "sepal_width") \
.add_legend();
plt.show();
@ishritam
ishritam / pairplot
Created October 9, 2019 07:58
pairplot
sns.set_style("whitegrid");
sns.pairplot(iris, hue="species", size=2);
plt.show()
# NOTE: the diagnol elements are PDFs for each feature. PDFs are expalined below.
@ishritam
ishritam / 1-D scatter plot
Created October 9, 2019 08:10
1-D scatter plot
#1-D scatter plot of petal-length
import numpy as np
iris_setosa = iris.loc[iris["species"] == "setosa"];
iris_virginica = iris.loc[iris["species"] == "virginica"];
iris_versicolor = iris.loc[iris["species"] == "versicolor"];
plt.plot(iris_setosa["petal_length"], np.zeros_like(iris_setosa['petal_length']), 'o')
plt.plot(iris_versicolor["petal_length"], np.zeros_like(iris_versicolor['petal_length']), 'o')
plt.plot(iris_virginica["petal_length"], np.zeros_like(iris_virginica['petal_length']), 'o')
@ishritam
ishritam / sns histogram
Created October 9, 2019 08:16
sns histogram
sns.FacetGrid(iris, hue="species", size=5) \
.map(sns.distplot, "petal_length") \
.add_legend();
plt.show();
@ishritam
ishritam / Plot CDF of petal_length
Last active October 9, 2019 11:00
Plot CDF of petal_length
#Plot CDF of petal_length
counts, bin_edges = np.histogram(iris_setosa['petal_length'], bins=10,
density = True)
pdf = counts/(sum(counts))
print(pdf);
print(bin_edges)
#compute CDF
cdf = np.cumsum(pdf)
@ishritam
ishritam / violinplot
Created October 9, 2019 11:47
violinplot
sns.violinplot(x="species", y="petal_length", data=iris, size=8)
plt.show()
@ishritam
ishritam / 2D Density plot
Created October 9, 2019 11:52
2D Density plot
#2D Density plot, contors-plot
sns.jointplot(x="petal_length", y="petal_width", data=iris, kind="kde");
plt.show();
@ishritam
ishritam / Data Standardization
Last active November 3, 2019 12:19
Data Standardization
%matplotlib inline
import matplotlib.pyplot as plt
Sepal_Width_new = [0.77, -0.77, -0.15, -0.46, 1.08, 1.38, 0.46, 0.46, -1.0, -1.6]
plt.plot(Sepal_Width_new)