Created
February 16, 2021 04:57
-
-
Save ksv-muralidhar/090a2a14b2c898a253c2ac734dc2d841 to your computer and use it in GitHub Desktop.
Gauusian Tests
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 matplotlib.pyplot as plt | |
from sklearn.datasets import load_iris | |
#Converting the data from an array to a data frame | |
X = pd.DataFrame(load_iris()["data"]).copy() |
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
X.hist(figsize=(10,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
fig,ax = plt.subplots(2,2,figsize=(10,10)) | |
row = col = 0 | |
for n,c in enumerate(X.columns): | |
if (n%2 == 0) & (n > 0): | |
row += 1 | |
col = 0 | |
X[c].plot(kind="kde",ax=ax[row,col]) | |
ax[row,col].set_title(c) | |
col += 1 |
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
from scipy.stats import probplot | |
for i in X.columns: | |
probplot(x=X[i],dist='norm',plot=plt) | |
plt.title(i) | |
plt.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
from scipy.stats import shapiro | |
for i in X.columns: | |
print(f'{i}: {"Not Gaussian" if shapiro(X[i])[1]<0.05 else "Gaussian"} {shapiro(X[i])}') |
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
from scipy.stats import kstest | |
np.random.seed(11) | |
normal_dist = np.random.randn(1000) | |
pd.Series(normal_dist).plot(kind="kde") | |
print(f'{"Not Gaussian" if kstest(normal_dist,"norm")[1]<0.05 else "Gaussian"} {kstest(normal_dist,"norm")}') |
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
from scipy.stats import kstest | |
for i in X.columns: | |
print(f'{i}: {"Not Gaussian" if kstest(X[i].values,"norm")[1]<0.05 else "Gaussian"} {kstest(X[i].values,"norm")}') |
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
from scipy.stats import normaltest | |
for i in X.columns: | |
print(f'{i}: {"Not Gaussian" if normaltest(X[i].values,)[1]<0.05 else "Gaussian"} {normaltest(X[i].values)}') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment