Python Data Science Tutorial
Python Data Processing
Python Data Visualization
Statistical Data Analysis
Selected Reading
- Python Data Science - Matplotlib
- Python Data Science - SciPy
- Python Data Science - Numpy
- Python Data Science - Pandas
- Python Data Science - Environment Setup
- Python Data Science - Getting Started
- Python Data Science - Home
Python Data Processing
- Python Stemming and Lemmatization
- Python word tokenization
- Python Processing Unstructured Data
- Python Reading HTML Pages
- Python Data Aggregation
- Python Data Wrangling
- Python Date and Time
- Python NoSQL Databases
- Python Relational databases
- Python Processing XLS Data
- Python Processing JSON Data
- Python Processing CSV Data
- Python Data cleansing
- Python Data Operations
Python Data Visualization
- Python Graph Data
- Python Geographical Data
- Python Time Series
- Python 3D Charts
- Python Bubble Charts
- Python Scatter Plots
- Python Heat Maps
- Python Box Plots
- Python Chart Styling
- Python Chart Properties
Statistical Data Analysis
- Python Linear Regression
- Python Chi-square Test
- Python Correlation
- Python P-Value
- Python Bernoulli Distribution
- Python Poisson Distribution
- Python Binomial Distribution
- Python Normal Distribution
- Python Measuring Variance
- Python Measuring Central Tendency
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Python Chi-square Test
Python - Chi-Square Test
Chi-Square test is a statistical method to determine if two categorical variables have a significant correlation between them. Both those variables should be from same population and they should be categorical pke − Yes/No, Male/Female, Red/Green etc. For example, we can build a data set with observations on people s ice-cream buying pattern and try to correlate the gender of a person with the flavour of the ice-cream they prefer. If a correlation is found we can plan for appropriate stock of flavours by knowing the number of gender of people visiting.
We use various functions in numpy pbrary to carry out the chi-square test.
from scipy import stats import numpy as np import matplotpb.pyplot as plt x = np.pnspace(0, 10, 100) fig,ax = plt.subplots(1,1) pnestyles = [ : , -- , -. , - ] deg_of_freedom = [1, 4, 7, 6] for df, ls in zip(deg_of_freedom, pnestyles): ax.plot(x, stats.chi2.pdf(x, df), pnestyle=ls) plt.xpm(0, 10) plt.ypm(0, 0.4) plt.xlabel( Value ) plt.ylabel( Frequency ) plt.title( Chi-Square Distribution ) plt.legend() plt.show()
Its output is as follows −
Advertisements