avatarNaina Chaturvedi

Summary

The undefined website content outlines the "Day 5 of 30 days of Data Analytics with Projects Series," providing an overview of statistics in data analytics, including measures of center, spread, and data types, along with practical Python code examples and announcements of related educational content and resources.

Abstract

The provided content from the undefined website delves into the fifth day of a comprehensive 30-day series focused on data analytics with practical projects. It introduces the importance of statistics in understanding data, covering fundamental concepts such as measures of center (mean, median, mode) and measures of spread (standard deviation, inter-quartile range, variance). The article also distinguishes between categorical and numeric data types, emphasizing their significance in data analysis. Additionally, it offers Python code snippets using libraries like NumPy and SciPy to illustrate statistical calculations and data visualization techniques. The content also teases the upcoming topics in the series and promotes the author's educational newsletter, "Tech Brew," alongside other related series and projects on platforms like Medium and Substack.

Opinions

  • The author values the practical application of statistical concepts in data analytics, as evidenced by the inclusion of Python code examples.
  • There is an emphasis on the educational aspect of the series, with the author encouraging readers to subscribe for more in-depth content and updates.
  • The content suggests a positive outlook on the usefulness of understanding statistics for making data-driven decisions in various domains such as advertising and optimization problems.
  • The author seems to prioritize reader engagement and learning by inviting questions in the comment section and providing a variety of resources for further exploration.
  • There is an opinion that learning system design is crucial for tech professionals, as indicated by the mention of system design base concepts and case studies.
  • The author conveys enthusiasm about the field of data analytics and its potential to drive business decisions, as shown by the promotion of their newsletter and other tech-related content.

Day 5 of 30 days of Data Analytics with Projects Series

Pic credits : osu

Welcome back peeps. Happy to share that we have just finished —

Finished Series —

15 days of Advanced SQL Series

30 days of Data Structures and Algorithms Series

14 System Design Case Studies Series

60 Days of Data Science and Machine Learning with projects Series

Complete System Design with most popular Questions Series

Projects Videos —

All the projects, data structures, SQL, algorithms, system design, Data Science and ML , Data Analytics, Data Engineering, , Implemented Data Science and ML projects, Implemented Data Engineering Projects, Implemented Deep Learning Projects, Implemented Machine Learning Ops Projects, Implemented Time Series Analysis and Forecasting Projects, Implemented Applied Machine Learning Projects, Implemented Tensorflow and Keras Projects, Implemented PyTorch Projects, Implemented Scikit Learn Projects, Implemented Big Data Projects, Implemented Cloud Machine Learning Projects, Implemented Neural Networks Projects, Implemented OpenCV Projects,Complete ML Research Papers Summarized, Implemented Data Analytics projects, Implemented Data Visualization Projects, Implemented Data Mining Projects, Implemented Natural Leaning Processing Projects, MLOps and Deep Learning, Applied Machine Learning with Projects Series, PyTorch with Projects Series, Tensorflow and Keras with Projects Series, Scikit Learn Series with Projects, Time Series Analysis and Forecasting with Projects Series, ML System Design Case Studies Series videos will be published on our youtube channel ( just launched).

Subscribe today!

We are now starting a new series — 30 days of Data Analytics with Projects. This series would run in parallel with —

Ongoing Series —

30 days of Data Engineering Series

30 days of MLOps

30 days of Deep Learning Series

ML Research ( papers) Simplified

What’s covered till now —

Day 1 : Data Analytics basics and kickstart of Data analytics with projects series

Day 2: Business Understanding — Data Driven Decision Making, Descriptive Analysis, Predictive Analysis, Diagnostic Analysis, Prescriptive Analysis

Day 3 : Data Analytics Ecosystem — Data Life Cycle, Data Analysis complete process ( most important things)

Day 4 : Probability, Conditional Probability, Binomial Distribution, Probability Density Function, Sampling Distribution

Day 5 : Statistics

In the last post we covered Probability and for this post we will cover Statistics.

First understand, Why Statistics?

As we uncover the power of stats, there are numerous questions which stats can help you answer, like ( and the list doesn’t ends here) —

  • Ads Targeting and optimization — Which ad is more effective in getting people to purchase a product?
  • Optimization — How can you optimize occupancy in a hotel based on the previous occupancy history data?
  • Consumer behaviour and insights — How likely is someone to purchase a product? What payment system are they going to use based on their purchasing history data?
  • Patterns — What the most fitting size of t-shirts based on the what 95% of the population is wearing?

Statistics is a field of study that involves the collection, analysis, interpretation, presentation, and organization of data.

To understand statistics, it is important to know the following:

  1. Descriptive statistics: This involves summarizing and describing the characteristics of a dataset, such as measures of central tendency (mean, median, mode) and measures of dispersion (range, variance, standard deviation).
  2. Probability: Understanding basic concepts of probability, such as independent and dependent events, conditional probability, and Bayes’ theorem, is essential for statistics.
  3. Inferential statistics: This involves using a sample of data to make inferences about a population, such as estimation of population parameters and hypothesis testing.
  4. Data visualization: Visual representation of data using graphs and charts helps to understand and interpret data easily.
  5. Linear regression and correlation: Linear regression is a statistical method used to study the relationship between two continuous variables. Correlation is used to measure the strength of the relationship between two variables.
  6. Sampling: Understanding different sampling methods, such as random sampling, stratified sampling, and cluster sampling, is important for collecting data.
  7. Experimental design: This refers to the planning and execution of experiments, including the control of variables and randomization to minimize bias.

Branches of statistics

Knowing the type of statistics you need to answer your question will help you choose the appropriate methods to get the most accurate answer possible.

Pic credits : sixsigma

There are two branches of statistics —

Inferential statistics — It takes sample data in order to make inferences with respect to a larger population.

Example —

What % of students drive to college by inferring to the sample data.

import scipy.stats as stats

data = [1, 2, 3, 4, 5]  # Sample data
sample_mean = sum(data) / len(data)  # Sample mean
t_stat, p_value = stats.ttest_1samp(data, population_mean)  # One-sample t-test
confidence_interval = stats.t.interval(0.95, len(data)-1, loc=sample_mean, scale=stats.sem(data))  # Confidence interval

Descriptive statistics — It describes and summarize the data

Example —

How do the students get to their college. Answer can be that 40% of them drive to work, 35% ride the bus, and 25% bike etc.

Pic credits : Reddit
data = [1, 2, 3, 4, 5]  # Sample data
mean = sum(data) / len(data)  # Mean
median = stats.median(data)  # Median
mode = stats.mode(data)  # Mode
range_val = max(data) - min(data)  # Range

There are two types of data —

Pic credits : pdfprof

Categorical, or qualitative data: It’s made up of values that belong to distinct groups which is further divided into Nominal and Ordinal. For this type of data we use summary statistics such as counts and plots like barplots etc

Numeric, or quantitative data : It’s made up of numeric values which is further divided into Discrete ( counted items) and Continuous( measured variables). For this type of data we can use summary statistics like mean, and plots like scatter plots etc

Examples of Quantitative Data — Discrete : No of schools, no of children, no of births/hour, Continuous — Weight, Height, Volume etc

Examples of Qualitative data — Marital status, Type of disease, Eye Color etc

Measure of Centre

It’s the value at the center or middle of the data set.

There are four measures of centre —

  • Mean- It’s a preferred measure for the interval data
  • Median- It’s a preferred measure for the ordinal data
  • Mode — It’s a preferred measure for the nominal data
  • Range
Pic credits: meaningmania
data = [1, 2, 3, 4, 5]  # Sample data
mean = sum(data) / len(data)  # Mean
median = stats.median(data)  # Median
mode = stats.mode(data)  # Mode
Pic credits : Pinterest

Measure of Spread/ Measure of Variation —

Variability is the key to the statistics. So, when you are describing the data, never rely on the center alone. Measure of spread identified the spread of the values.

There are four measures of spread/variation —

  1. Standard Deviation
import math

data = [1, 2, 3, 4, 5]  # Sample data
mean = sum(data) / len(data)  # Mean
variance = sum((x - mean) ** 2 for x in data) / len(data)  # Variance
std_dev = math.sqrt(variance)  # Standard deviation

2. Inter-Quartile Range ( IQR)

import numpy as np

data = [1, 2, 3, 4, 5]  # Sample data
q1, q3 = np.percentile(data, [25, 75])  # 1st quartile, 3rd quartile
iqr = q3 - q1  # Inter-quartile range

3. Variance

data = [1, 2, 3, 4, 5]  # Sample data
mean = sum(data) / len(data)  # Mean
variance = sum((x - mean) ** 2 for x in data) / len(data)  # Variance

Measure of frequency : Shows how often a value occurs

Pic credits : mathson
Pic credits : mathson

Which measure to use?

  • If the distribution is normal or symmetrical, use mean and standard deviation. Mean works better for symmetrical data and is more sensitive to extreme values.
  • If the distribution is skewed or has large outliers, then use Median, Range or IQR. Median is usually better to use when your data is skewed i.e not symmetrical.
  • If the distribution is bimodal, Use mode to figure out if the two modes represent different groups , or range.

Numpy Statistical Functions

Along the specified axis and the given data set , below are the statistical functions that you can use to analyze your data —

np.mean()- To determines the mean value

np.median()- To determines the median value

np.std()- To determines the standard deviation

np.var() — To determines the variance

np.average()- To determines the weighted average

np.percentile()- To determines the nth percentile

np.amin()- To determines the minimum value

np.amax()- To determines the maximum value

Implementation —

import numpy as np
arr1= np.array([[12,43,56],[78,88,95],[79,89,43], [101,34,67]]) 
arr2 = np.array([5,6,7,12,34,67,89]) 
#Mean function
print("Mean:", np.mean(arr2))
#Median function
print("Median:",np.median(arr2))
#Standard Deviation Function
print("Standard Deviation:", np.std(arr2))
#Variance Function
print("Variance:",np.var(arr2))
#Average Function
print("Average:",np.average(arr2))
#Percentile Function
print("Percentile:",np.percentile(arr2,5,0))
#Minimum Function
print("Minimum element:",np.amin(arr))
#Maximum Function
print("Maximum element:",np.amax(arr))

Output —

Mean: 31.428571428571427
Median: 12.0
Standard Deviation: 31.409084867994768
Variance: 986.530612244898
Average: 31.428571428571427
Percentile: 5.3
Minimum element: 12
Maximum element: 101

Measure of Spread

Quantiles are a great way of summarizing numerical data since they can be used to measure center and spread, as well as to get a sense of where a data point stands in relation to the rest of the data set. For example, you might want to give a discount to the 20% most active users on a website.

data = [1, 2, 3, 4, 5]  # Sample data
range_val = max(data) - min(data)  # Range
iqr = stats.iqr(data)  # Inter-quartile range
variance = sum((x - mean) ** 2 for x in data) / len(data)  # Variance
std_dev = math.sqrt(variance)  # Standard deviation

Numpy Quartiles : numpy.quantile(arr, q, axis ) : Compute the qth quantile of the given data

Pic credits : Pinterest

Interquartile range, or IQR, used to measure spread that’s less influenced by outliers and to find the outliers.

If a value is less than Q1−1.5×IQR or greater than Q3+1.5×IQR then it’s considered an outlier.

Calculate the lower and upper cutoffs for outliers

  • lower = q1–1.5 * iqr
  • upper = q3 + 1.5 * iqr

Implementation —

arr = [31, 35, 45, 49, 59, 69, 74, 79, 80, 81, 89, 94, 96, 99, 101, 104, 112, 117,119,127,134]
  
# First quartile (Q1)
Q1 = np.median(arr[:12])
  
# Third quartile (Q3)
Q3 = np.median(arr[12:])
  
# Interquartile range (IQR)
IQR = Q3 - Q1
  
print(IQR)

Output —

40.5

Continuous Probability distribution

Distribution with location (loc) and Scale (scale) parameters.Continuous distributions can be uniform or can take forms where some values have a higher probability than others.

Pic credits : slideserv

Implementation —

from scipy.stats import uniform
arr2 = np.array([5,6,7,12,34,67,89]) 
print (uniform.cdf(arr2, loc =4 , scale = 5))

Output —

[0.2 0.4 0.6 1.  1.  1.  1. ]

That’s it for now. Day 6:

Let me know if you have questions in the comment section below. Subscribe/ Follow, Like/Clap as it would encourage me to write more in my free time

Stay Tuned!!

Read More —

11 most important System Design Base Concepts

1. System design basics

2. Horizontal and vertical scaling

3. Load balancing and Message queues

4. High level design and low level design, Consistent Hashing, Monolithic and Microservices architecture

5. Caching, Indexing, Proxies

6. Networking, How Browsers work, Content Network Delivery ( CDN)

7. Database Sharding, CAP Theorem, Database schema Design

8. Concurrency, API, Components + OOP + Abstraction

9. Estimation and Planning, Performance

10. Map Reduce, Patterns and Microservices

11. SQL vs NoSQL and Cloud

12. Most Popular System Design Questions

13. System Design Template — How to solve any System Design Question

14. Quick RoundUp : Solved System Design Case Studies

System Design Case Studies — In Depth

Design Instagram

Design Messenger App

Design Twitter

Design URL Shortener

Design Dropbox

Design Youtube

Design API Rate Limiter

Design Web Crawler

Design Facebook’s Newsfeed

Design Yelp

Design Uber

Design Tinder

Design Tiktok

Design Whatsapp

Most Popular System Design Questions

Mega Compilation : Solved System Design Case studies

Complete Data Structures and Algorithm Series

Complexity Analysis

Backtracking

Sliding Window

Greedy Technique

Two pointer Technique

Arrays

Linked List

Strings

Stack

Queues

Hash Table/Hashing

Binary Search

1- D Dynamic Programming

Divide and Conquer Technique

Recursion

Some of the other best Series —

60 days of Data Science and ML Series with projects

30 Days of Natural Language Processing ( NLP) Series

30 days of Machine Learning Ops

30 days of Data Structures and Algorithms and System Design Simplified

60 Days of Deep Learning with Projects Series

30 days of Data Engineering with projects Series

Data Science and Machine Learning Research ( papers) Simplified **

100 days : Your Data Science and Machine Learning Degree Series with projects

23 Data Science Techniques You Should Know

Tech Interview Series — Curated List of coding questions

Complete System Design with most popular Questions Series

Complete Data Visualization and Pre-processing Series with projects

Complete Python Series with Projects

Complete Advanced Python Series with Projects

Kaggle Best Notebooks that will teach you the most

Complete Developers Guide to Git

Exceptional Github Repos — Part 1

Exceptional Github Repos — Part 2

All the Data Science and Machine Learning Resources

210 Machine Learning Projects

Tech Newsletter —

If you are interested, you can join my newsletter through which I send tech interview tips, techniques, patterns, hacks — Software Development, ML, Data Science, Startups and Technology projects to more than 30K readers. You can subscribe to Tech Brew :

For Python Projects —

For complete 60 days of Data Science and ML : Day 1 — Day 60 : Quick Recap of 60 days of Data Science and ML

Follow for more updates. Stay tuned and keep coding!

For other projects, tune to —

Build Machine Learning Pipelines( With Code)

Recurrent Neural Network with Keras

Clustering Geolocation Data in Python using DBSCAN and K-Means

Facial Expression Recognition using Keras

Hyperparameter Tuning with Keras Tuner

Custom Layers in Keras

Data Science
Machine Learning
Tech
Programming
Artificial Intelligence
Recommended from ReadMedium