Data Science & Machine Learning
77.7K subscribers
901 photos
1 video
68 files
820 links
Join this channel to learn data science, artificial intelligence and machine learning with funny quizzes, interesting projects and amazing resources for free

For collaborations: @love_data
Download Telegram
What will be the output of the following Python code?
import statistics
numbers = [10, 20, 30] print(round(statistics.pstdev(numbers), 2))
Anonymous Quiz
12%
10
32%
20
15%
8
41%
8.16
❤2
In Data Science, Standard Deviation is commonly used for which of the following?
Anonymous Quiz
3%
A) Creating folders
91%
B) Measuring data variability and feature scaling
2%
C) Designing web pages
4%
D) Connecting to databases
❤2
🚀 Data Science Roadmap 2026

📘 Phase 2: Mathematics for Data Science

📖 Topic 4: Probability Basics

Welcome back! 👋

In the previous lesson, you learned about Variance and Standard Deviation, which help us understand how data is spread out.

Now let's learn another fundamental concept in Data Science: Probability.

Probability helps us measure the likelihood that an event will happen. It plays an important role in Machine Learning, Statistics, Bayesian inference, risk analysis, forecasting, and decision-making.

🔹 1. What is Probability?

Probability is a measure of how likely an event is to occur.

Its value ranges from: 0 ≤ Probability ≤ 1

Where:

0 → Impossible event

1 → Certain event

0.5 → 50% chance

Probability can also be expressed as a percentage.

0.25 = 25%

0.50 = 50%

0.75 = 75%

1.00 = 100%

🔹 2. Basic Probability Formula

When all possible outcomes are equally likely:

Probability(Event) =

Number of favorable outcomes

────────────────────────────

Total number of possible outcomes

Example

Roll a standard six-sided die: 1, 2, 3, 4, 5, 6

What is the probability of getting a "4"?

1 favorable outcome, 6 possible outcomes

P(4) = 1/6 ≈ 0.167 = 16.7%

🔹 3. Experiment, Outcome & Event

Experiment: An action that produces an outcome. Ex: Rolling a die

Outcome: A possible result. Ex: 1, 2, 3, 4, 5, or 6

Event: A specific outcome or group of outcomes we're interested in. Ex: Getting an even number → 2, 4, 6

🔹 4. Sample Space

The set of all possible outcomes.

Coin toss: S = {Head, Tail}

Die: S = {1, 2, 3, 4, 5, 6}

🔹 5. Probability of an Event

Roll a die and want an even number.

Favorable: 2, 4, 6

P(Even) = 3/6 = 0.5 = 50%

🔹 6. Complementary Probability ⭐

The complement of an event means the event does not happen.

If P(A) = 0.7

Then: P(Not A) = 1 - P(A) = 1 - 0.7 = 0.3

So there is a 30% probability that A will not occur.

🔹 7. Independent Events

Two events are independent when the occurrence of one does not affect the other.

Ex: Tossing a coin twice.

For independent events: P(A and B) = P(A) × P(B)

Ex: P(Head and Head) = 1/2 × 1/2 = 1/4 = 25%

🔹 8. Dependent Events

Two events are dependent when the outcome of one affects the probability of the other.

Ex: Bag with 3 Red, 2 Blue balls. Pick one and don't put it back. The probability for the second pick changes.

🔹 9. Conditional Probability ⭐

Probability of an event occurring given that another event has already occurred.

Written as: P(A | B) → "Probability of A given B"

Formula: P(A | B) = P(A ∩ B) / P(B)

🔹 10. Real-World Example of Conditional Probability

Company data:

60% customers using Mobile App

30% customers using Mobile App and making a purchase

P(Purchase | App) = P(Purchase ∩ App) / P(App) = 0.30 / 0.60 = 0.50

Therefore: 50% of app users make a purchase.

🔹 11. Addition Rule

For two events: P(A or B) = P(A) + P(B) - P(A and B)

If mutually exclusive: P(A or B) = P(A) + P(B)

🔹 12. Multiplication Rule

For independent events: P(A and B) = P(A) × P(B)

Ex: Rolling two sixes: P(6 and 6) = 1/6 × 1/6 = 1/36

🔹 13. Probability in Data Science ⭐

Machine Learning: Models produce probabilities. Ex: P(Spam) = 0.92

Classification: P(Customer will churn) = 78%

Risk Analysis: Estimate likelihood of loan default, fraud, churn, equipment failure

🔹 14. Probability vs Statistics

Probability: Starts with assumptions and predicts possible outcomes. Known model → Predict outcomes

Statistics: Starts with observed data and tries to understand the underlying population. Observed data → Learn about the model

🔹 15. Python Example

favorable = 3
total = 6
probability = favorable / total
print(probability)
❤6
Output: 0.5 → 50%

🔹 16. Common Mistakes

❌ Probability can be greater than 1 

Incorrect: Probability = 1.5 

Correct range: 0 ≤ P(A) ≤ 1

❌ Confusing independent and mutually exclusive events

Independent: One event does not affect the other

Mutually exclusive: Both events cannot occur at the same time

🎯 Practice Questions

1. What is the probability of getting Heads when tossing a fair coin?

2. What is the probability of rolling an even number on a six-sided die?

3. If P(A) = 0.8, what is P(Not A)?

4. What is the probability of getting two Heads when tossing a fair coin twice?

5. Explain the difference between independent and dependent events.

🎯 Key Takeaways

✅ Probability measures the likelihood of an event

✅ Probability ranges from "0" to "1"

✅ Sample space contains all possible outcomes

✅ Complementary probability is "1 - P(A)"

✅ Independent events do not affect each other

✅ Dependent events affect each other's probabilities

✅ Conditional probability measures the probability of an event given another event

✅ Probability is fundamental to Machine Learning, classification, risk analysis, and statistical inference

Understanding probability is essential before moving into more advanced topics such as Bayes' Theorem, probability distributions, hypothesis testing, and machine learning algorithms.

Double Tap ❤️ For More
❤4👍1
🚀 Data Science Roadmap 2026

📘 Phase 2: Mathematics for Data Science

📖 Topic 5: Bayes' Theorem

Welcome back! 👋

In the previous lesson, you learned the fundamentals of Probability. Now we're moving to one of the most important concepts in probability and statistics for Data Science: Bayes' Theorem.

Bayes' Theorem helps us update the probability of an event when we receive new information.

It is particularly important in:

✅ Machine Learning

✅ Classification

✅ Medical diagnosis

✅ Fraud detection

✅ Spam detection

✅ Risk analysis

✅ Recommendation systems

🔹 1. What is Bayes' Theorem?

Bayes' Theorem calculates the probability of an event based on prior knowledge and new evidence.

In simple terms:

«Start with what you already know → receive new evidence → update your belief.»

🔹 2. Bayes' Theorem Formula ⭐

The formula is:

P(A|B) = P(B|A) × P(A)/P(B)

Where:

• P(A|B) → Probability of A given B

• P(B|A) → Probability of B given A

• P(A) → Prior probability of A

• P(B) → Probability of B

🔹 3. Understanding the Terms

Suppose we're trying to determine whether an email is spam.

Event A: Email is Spam

Evidence B: Email contains the word "Free"

Then: P(Spam | "Free") means: Probability that the email is spam given that it contains the word "Free".

🔹 4. Prior Probability

The prior probability represents what we believe before considering new evidence.

Suppose: 10% of all emails are spam.

P(Spam) = 0.10

This is our initial belief.

🔹 5. Likelihood

Now suppose: 80% of spam emails contain the word "Free".

P("Free" | Spam) = 0.80

This tells us how likely the evidence is if the email is actually spam.

🔹 6. Posterior Probability

After seeing the evidence, we want to calculate:

P(Spam | "Free")

This is called the posterior probability.

It represents our updated belief after receiving new information.

🔹 7. Simple Numerical Example ⭐

Suppose:

• P(Spam) = 0.10

• P(Free | Spam) = 0.80

• P(Free) = 0.20

Using Bayes' Theorem:

P(Spam | Free) = P(Free | Spam) × P(Spam)/P(Free)

= 0.80 × 0.10/0.20

= 0.08/0.20

= 0.40

Therefore: P(Spam | Free) = 40%

So after seeing the word "Free", our estimated probability that the email is spam increases from 10% to 40%.

🔹 8. Why Does Bayes' Theorem Matter?

Bayes' Theorem allows us to update probabilities when new evidence becomes available.

This is extremely useful when working with uncertain information.

Initial belief → New evidence → Updated probability

🔹 9. Bayes' Theorem in Machine Learning ⭐

One of the most famous applications is Naive Bayes.

Naive Bayes is a classification algorithm based on Bayes' Theorem.

It can be used for:

• Spam detection

• Sentiment analysis

• Text classification

• Document classification

• News classification

Example: Email → Extract words → Calculate probabilities → Spam probability = 92% → Classify as Spam

🔹 10. Medical Diagnosis Example

Suppose a disease is relatively rare. 1% of people have a disease.

A medical test is positive for 90% of people who have the disease.

At first glance, a positive test might seem to mean that the person almost certainly has the disease.
❤5
But that's not necessarily true. We also need to consider: 

• How common the disease is 

• How often the test produces false positives 

• How accurate the test is 

Bayes' Theorem combines all of this information to calculate the probability of actually having the disease given a positive test. This is called the base-rate effect.

🔹 11. Fraud Detection Example

Suppose a bank monitors transactions. Initially: P(Fraud) = 1%

A transaction contains unusual characteristics.

The system uses historical data to determine: P(Unusual | Fraud)

Bayes' Theorem can then help estimate: P(Fraud | Unusual)

The bank can use this probability to decide whether the transaction should be investigated.

🔹 12. Bayes' Theorem vs Conditional Probability

Conditional Probability answers: "What is the probability of A given B?" → $P(A|B)$

Bayes' Theorem provides a way to calculate that probability by using the reverse conditional probability:

P(A|B) = P(B|A)P(A)/P(B)

So Bayes' Theorem allows us to reverse conditional probabilities and update our beliefs using evidence.

🔹 13. Prior vs Likelihood vs Posterior ⭐

Prior: What we believe before seeing new evidence. → $P(A)$

Likelihood: How likely the evidence is assuming A is true. → $P(B|A)$

Posterior: What we believe after considering the evidence. → $P(A|B)$ 

A simple way to remember: Prior + Evidence → Posterior

🔹 14. Python Example

Bayes' Theorem can be implemented directly in Python:
prior = 0.10
likelihood = 0.80
evidence = 0.20

posterior = (likelihood * prior) / evidence
print(posterior)

Output:
0.4

So the posterior probability is: 40%

🔹 15. Common Mistake ⭐

A common mistake is confusing: P(A|B) with P(B|A)

They are generally not equal.

For example: P(Disease | Positive Test) is not necessarily the same as P(Positive Test | Disease)

This distinction is extremely important in statistics and Machine Learning.

🎯 Practice Questions

1. Write the formula for Bayes' Theorem.

2. What is the difference between prior and posterior probability?

3. What does "P(A|B)" mean?

4. Give two real-world applications of Bayes' Theorem.

5. Why is Bayes' Theorem useful in spam detection?

🎯 Key Takeaways

✅ Bayes' Theorem updates probability using new evidence.

✅ The basic formula is: P(A|B)=P(B|A)P(A)/P(B)

✅ Prior probability represents our initial belief.

✅ Likelihood measures how likely the evidence is under an assumption.

✅ Posterior probability represents our updated belief.

✅ Bayes' Theorem is the foundation of algorithms such as Naive Bayes.

✅ It is widely used in spam detection, medical diagnosis, fraud detection, classification, and risk analysis.

The key idea to remember is:

«Bayes' Theorem helps us update what we believe when new evidence becomes available.»

Double Tap ❤️ For More
❤8🔥3
🚀 𝗚𝗼𝗼𝗴𝗹𝗲 𝗙𝗥𝗘𝗘 𝗖𝗲𝗿𝘁𝗶𝗳𝗶𝗰𝗮𝘁𝗶𝗼𝗻 𝗖𝗼𝘂𝗿𝘀𝗲𝘀 𝟮𝟬𝟮𝟲 🎓

Want to upgrade your resume with Google skills and certifications Explore FREE learning opportunities and build in-demand skills for today's job market.

👉Artificial Intelligence & Generative AI
📊 Data Analytics
☁️ Cloud Computing
📢 Digital Marketing
🔐 Cybersecurity
💻 Tech & Career Skills

𝗘𝗻𝗿𝗼𝗹𝗹 𝗙𝗼𝗿 𝗙𝗥𝗘𝗘👇:- 

https://pdlink.in/4z9pdgf

🔥 Don't just collect certificates — build skills that can help you stand out in 2026!
❤2👍1🔥1
Which Machine Learning algorithm is directly based on Bayes' Theorem?
Anonymous Quiz
18%
A) K-Means
11%
B) Random Forest
63%
C) Naive Bayes
8%
D) Linear Regression
🚀 DATA ANALYTICS + AI: YOUR NEXT CAREER MOVE!

Data is everywhere. The right skills can put you ahead.
Join the PW Skills Data Analytics With AI Course and learn Excel, SQL, Python, Power BI & AI tools through live sessions and real-world projects.

✨ What you get:
✅ Industry-relevant Data Analytics skills
✅ AI-powered learning
✅ Microsoft collaboration
✅ Hands-on projects
✅ Job assistance*
✅ Live classes in Hinglish

📅 Starts: 14th August 2026
⏳ Duration: 5 Months
🔥 Ready to become a future-ready Data Analyst?
👉
Enroll Now & Start Your Upskilling Journey!
https://lp.pwskills.com/data-analytics-with-gen-ai-online-course?utm_source=telegram&utm_medium=influencer&utm_campaign=deepakDAonline
❤8🎉1
🇮🇳 𝗙𝗥𝗘𝗘 𝗚𝗼𝘃𝗲𝗿𝗻𝗺𝗲𝗻𝘁-𝗖𝗲𝗿𝘁𝗶𝗳𝗶𝗲𝗱 𝗢𝗻𝗹𝗶𝗻𝗲 𝗖𝗼𝘂𝗿𝘀𝗲𝘀 🎓

Upgrade your skills with *SWAYAM*, an initiative by the Government of India!

✅ Learn from leading institutes and expert educators
✅ Courses in AI, Programming, Data Science, Business & more
✅ Suitable for students, freshers and professionals
✅ Learn online at your own pace
✅ Strengthen your résumé with valuable certifications

🔗 𝗘𝗻𝗿𝗼𝗹𝗹 𝗙𝗼𝗿 𝗙𝗥𝗘𝗘👇:- 

https://pdlink.in/4gc1MKx

📢 Share this opportunity with your friends and classmates!
❤4🎉1
𝗔𝗜 𝗘𝗻𝗴𝗶𝗻𝗲𝗲𝗿𝗶𝗻𝗴 𝗖𝗲𝗿𝘁𝗶𝗳𝗶𝗰𝗮𝘁𝗶𝗼𝗻 𝗖𝗼𝘂𝗿𝘀𝗲 😍

Build real AI products - not just prompts

🎯 Program Highlights:-

🚀 15+ AI Projects
👨‍🏫 Live Online Classes + 1-on-1 Mentorship
💼 End-to-End Placement Support
🤝 500+ Partner Companies
🎓 2000+ Students Placed
💰 Average Salary: ₹7.4 LPA
🏆 Highest Salary: ₹41 LPA

🔗 𝗕𝗼𝗼𝗸 𝗮 𝗙𝗥𝗘𝗘 𝗗𝗲𝗺𝗼 𝗖𝗹𝗮𝘀𝘀:-

https://pdlink.in/4fWJVID

🔥 Learn AI → Build Real Projects → Create Your Portfolio → Become Job Ready
❤2
📊 𝗠𝗶𝗰𝗿𝗼𝘀𝗼𝗳𝘁 𝗙𝗥𝗘𝗘 𝗣𝗼𝘄𝗲𝗿 𝗕𝗜 𝗖𝗲𝗿𝘁𝗶𝗳𝗶𝗰𝗮𝘁𝗶𝗼𝗻 𝗖𝗼𝘂𝗿𝘀𝗲 🚀

Want to start a career in Data Analytics & Business Intelligence? Learn Power BI through Microsoft learning modules and build practical, job-relevant analytics skills.

🎯 Perfect for Students | Freshers | Data Analyst Aspirants | Working Professionals

🔗 𝗘𝗻𝗿𝗼𝗹𝗹 𝗙𝗼𝗿 𝗙𝗥𝗘𝗘👇:- 

https://pdlink.in/4zhGTX6

🔥 Start learning Power BI and turn raw data into powerful business insights!
❤4🎉1
📊 𝗕𝘂𝗶𝗹𝗱 𝗬𝗼𝘂𝗿 𝗗𝗮𝘁𝗮 𝗔𝗻𝗮𝗹𝘆𝘀𝘁 𝗣𝗼𝗿𝘁𝗳𝗼𝗹𝗶𝗼 | 𝟱 𝗛𝗮𝗻𝗱𝘀-𝗢𝗻 𝗣𝗿𝗼𝗷𝗲𝗰𝘁𝘀 🚀

Learning Data Analytics? Don't stop with tutorials — build real projects that you can showcase on your resume and portfolio! 💻

🔥 Practice with 5 Hands-On Projects covering:

🗄️ SQL
📊 Excel
📈 Tableau
📉 Power BI

🔗𝗟𝗶𝗻𝗸 👇:- 

https://pdlink.in/45LLDH7

🎓 Perfect for Students | Freshers | Data Analyst Aspirants | Beginners
❤4🎉1
🚀 𝟰 𝗙𝗥𝗘𝗘 𝗖𝗼𝘂𝗿𝘀𝗲𝘀 𝘁𝗼 𝗕𝗼𝗼𝘀𝘁 𝗬𝗼𝘂𝗿 𝗥𝗲𝘀𝘂𝗺𝗲 & 𝗖𝗼𝗻𝗳𝗶𝗱𝗲𝗻𝗰𝗲 🎓🔥

Make your resume stand out and feel more confident during your job search.

🚀 Build confidence and a career-focused mindset

✅ 100% FREE
✅ Beginner Friendly
✅ Improve Your Resume
✅ Develop Career-Ready Skills
✅ Great for Students, Freshers & Professionals

🔗 𝗘𝗻𝗿𝗼𝗹𝗹 𝗙𝗼𝗿 𝗙𝗥𝗘𝗘👇:- 

https://pdlink.in/4gce062

🔥 Don't just apply for jobs — build the skills and confidence to stand out!
❤1👍1