Chi-Squared Test
Chi-squared test is a well-known test even for those who are starting with statistical machine learning. Here, this test is used to check whether two categorical variables are related or independent. And, it is assumed that the observations used in the calculation of the contingency table are independent. Python Codefrom scipy.stats import chi2_contingency
table = ...
stat, p, dof, expected = chi2_contingency(table)
Student’s t-test
Tests whether the means of two independent samples are significantly different. Observations in each sample are independent and identically distributed (iid). Observations in each sample are normally distributed. Observations in each sample have the same variance. Python Codefrom scipy.stats import ttest_ind
data1, data2 = ...
stat, p = ttest_ind(data1, data2)
Analysis of Variance Test (ANOVA)
ANOVA is another widely popular test which is used to test how independent two samples are of each other. Here the observations are assumed to follow a normal distribution without any change in the variance. Python Codefrom scipy.stats import f_oneway
data1, data2, ... = ...
stat, p = f_oneway(data1, data2, ...)
Shapiro-Wilk Test
This test is used to check whether the sample data has a Gaussian distribution. Python Codefrom scipy.stats import shapiro
data1 = ....
stat, p = shapiro(data)
D’Agostino’s K^2 Test
Similar to Shapiro-Wilk test, this too is used to check for Gaussian distribution in data samples. Python Codefrom scipy.stats import normaltest
data1 = ....
stat, p = normaltest(data)
Pearson’s Correlation Coefficient
A statistical test for checking correlation between two samples and whether they have a linear relationship. Python Codefrom scipy.stats import pearsonr
data1, data2 = ...
corr, p = pearsonr(data1, data2)
Spearman’s Rank Correlation
Observations in each sample are assumed that they can be ranked, for checking whether the relationship is monotonic or not. Python Codefrom scipy.stats import spearmanr
data1, data2 = ...
corr, p = spearmanr(data1, data2)
Mann-Whitney U Test
A non-parametric statistical hypothesis test to check for independent samples and to find whether the distributions are equal or not.
Python Code
from scipy.stats import mannwhitneyu
data1, data2 = ...
stat, p = mannwhitneyu(data1, data2)
Kruskal-Wallis H Test
Like previous tests, Kruskal-Wallis hypothesis test also makes the same assumptions regarding the distribution and ranking of the observations in each sample. And, the test is carried to check for the independence of the observations from each other. Python Codefrom scipy.stats import kruskal
data1, data2, ... = ...
stat, p = kruskal(data1, data2, ...)
Friedman Test
Friedman test checks whether the distributions of two or more paired samples are equal or not. Python Codefrom scipy.stats import friedmanchisquare
data1, data2, ... = ...
stat, p = friedmanchisquare(data1, data2, ...)


Your reaction