Introduction to Data Science and Machine Learning Foundations
From the https://www.youtube.com/live/YyT62Qy8OeE?si=xcSmf_r9XbjDQ0u1 curriculum
Introduction to Data Science and Machine Learning Foundations
TL;DR
Data science extracts insights from data, while machine learning uses data to build models that learn and make predictions. Both fields are interconnected and rely on a structured process involving data collection, preparation, modeling, and evaluation. Understanding these foundations is crucial for anyone looking to work with data to solve real-world problems.
1. The Mental Model
Think of data science as finding stories and patterns in mountains of information. Machine learning is like teaching a computer to read those stories and even write new ones based on what it's learned, without you explicitly telling it every single word.
2. The Core Material
Data science is an interdisciplinary field that uses scientific methods, processes, algorithms, and systems to extract knowledge and insights from structured and unstructured data. Machine learning is a subset of artificial intelligence (AI) that focuses on building systems that learn from data, identify patterns, and make decisions with minimal human intervention.
Data Science Workflow

Photo by ThisIsEngineering on Pexels
The data science process is often iterative and typically follows these steps:
- Problem Definition: Clearly understanding what you're trying to solve. What's the business question? What data do you need?
- Data Collection: Gathering relevant data from various sources (databases, APIs, web scraping, etc.).
- Data Cleaning & Preprocessing: This is often the most time-consuming step. It involves handling missing values, correcting errors, removing duplicates, and transforming data into a usable format. This step is also called "data wrangling" or "data preparation."
- Exploratory Data Analysis (EDA): Analyzing data to summarize its main characteristics, often with visual methods. This helps you understand the data's structure, identify patterns, and spot anomalies.
- Feature Engineering: Creating new variables or features from existing ones to improve the performance of machine learning models.
- Model Building: Selecting and training a machine learning model. This might involve choosing an algorithm (e.g., linear regression, decision tree) and fitting it to your prepared data.
- Model Evaluation: Assessing how well your model performs using various metrics (e.g., accuracy, precision, recall). This often involves splitting your data into training and testing sets.
- Deployment & Monitoring: Putting the model into production to make predictions on new, unseen data and continuously monitoring its performance.
graph TD
A["Problem Definition"] --> B["Data Collection"];
B --> C["Data Cleaning & Preprocessing"];
C --> D["Exploratory Data Analysis (EDA)"];
D --> E["Feature Engineering"];
E --> F["Model Building"];
F --> G["Model Evaluation"];
G --> H["Deployment & Monitoring"];
H --> A;
Types of Machine Learning

Photo by Markus Winkler on Pexels
There are three main types of machine learning:
- Supervised Learning: You train the model using labeled data, meaning each data point has a corresponding output or "correct answer." The goal is for the model to learn the mapping from input to output.
- Classification: Predicting a categorical label (e.g., spam/not spam, disease/no disease).
- Regression: Predicting a continuous numerical value (e.g., house price, temperature).
- Unsupervised Learning: You train the model using unlabeled data. The model tries to find hidden patterns or structures within the data on its own.
- Clustering: Grouping similar data points together (e.g., customer segmentation).
- Dimensionality Reduction: Reducing the number of features while retaining important information (e.g., for visualization or to simplify models).
- Reinforcement Learning: An agent learns to make decisions by performing actions in an environment and receiving rewards or penalties. It's like training a pet with treats.
Key Machine Learning Concepts

Photo by Markus Winkler on Pexels
- Features: The input variables used to predict the target. Also called predictors or independent variables.
- Target/Label: The output variable you want to predict. Also called dependent variable.
- Training Data: The data used to teach the model.
- Testing Data: Independent data used to evaluate the trained model's performance on unseen examples.
- Overfitting: When a model learns the training data too well, including its noise and outliers, and performs poorly on new data.
- Underfitting: When a model is too simple to capture the underlying patterns in the data, leading to poor performance on both training and new data.
3. Worked Example
Let's say you want to predict if a customer will churn (cancel their subscription).
1. Problem: Predict customer churn.
2. Data Collection: You gather historical customer data: usage minutes, contract type, monthly bill, age, gender, churn (Yes/No).
3. Cleaning: You find some monthly bill entries are missing; you decide to fill them with the average bill for similar contract types.
4. EDA: You plot monthly bill against usage minutes and notice customers with higher bills and lower usage tend to churn more. You also see that "Month-to-month" contract customers churn more frequently.
5. Feature Engineering: You create a new feature: bill_per_minute = monthly_bill / usage_minutes.
6. Model Building (Supervised Classification):
* You split your data into 80% training and 20% testing.
* You choose a Logistic Regression model because it's good for binary classification (churn/no churn).
* You train the model using the training data (usage_minutes, contract_type, monthly_bill, bill_per_minute as features, churn as the target).
```python
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import accuracy_score
# Sample Data (in a real scenario, this would be loaded from a file)
data = {
'usage_minutes': [100, 500, 200, 700, 150, 400, 900, 250],
'contract_type': ['Month-to-month', 'Yearly', 'Month-to-month', 'Yearly', 'Month-to-month', 'Yearly', 'Month-to-month', 'Yearly'],
'monthly_bill': [30, 60, 40, 80, 35, 55, 100, 45],
'churn': [1, 0, 1, 0, 1, 0, 1, 0] # 1 for churn, 0 for no churn
}
df = pd.DataFrame(data)
# Feature Engineering
df['bill_per_minute'] = df['monthly_bill'] / df['usage_minutes']
# Convert categorical feature 'contract_type' to numerical using one-hot encoding
df = pd.get_dummies(df, columns=['contract_type'], drop_first=True)
# Define features (X) and target (y)
X = df[['usage_minutes', 'monthly_bill', 'bill_per_minute', 'contract_type_Yearly']]
y = df['churn']
# Split data
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
# Model Building
model = LogisticRegression()
model.fit(X_train, y_train)
# Make predictions
y_pred = model.predict(X_test)
print(f"Predicted churn for test set: {y_pred}")
# Example Output: Predicted churn for test set: [0 0] (results vary slightly based on small data)
```
7. Model Evaluation: You use the test data to see how many customers the model correctly predicted would churn or not churn. You calculate an accuracy score.
python
print(f"Model accuracy on test set: {accuracy_score(y_test, y_pred)}")
# Example Output: Model accuracy on test set: 1.0 (very high due to tiny sample, not realistic)
8. Deployment: Once satisfied, you integrate this model into your customer retention system to flag high-risk customers proactively.
4. Key Takeaways
- Data science is about finding insights and patterns in data; machine learning is about building systems that learn from data.
- The data science workflow is an iterative process, not a linear one.
- Data cleaning and preprocessing are critical steps and often take the most time.
- Supervised learning uses labeled data for tasks like classification and regression.
- Unsupervised learning finds patterns in unlabeled data, such as clustering.
Common Mistakes to Avoid:
- Rushing data cleaning: Bad data leads to bad models ("Garbage in, garbage out").
- Overlooking the problem definition: Not clearly defining the problem often leads to irrelevant solutions.
- Training and testing on the same data: This gives an overly optimistic view of model performance.
- Ignoring domain knowledge: Expert insights can guide feature engineering and model selection.
5. Now Try It
Choose a simple dataset (e.g., Iris dataset, Boston Housing dataset, or even create a small one yourself). Spend 15 minutes trying to define a clear problem you want to solve with it (e.g., predict flower species, predict house price). Then, perform basic Exploratory Data Analysis (EDA) on it: look at the first few rows, check for missing values, and calculate basic statistics (mean, median, min, max). What initial insights can you gather from the data?
Frequently asked about Introduction to Data Science and Machine Learning Foundations
Get the full https://www.youtube.com/live/YyT62Qy8OeE?si=xcSmf_r9XbjDQ0u1 curriculum
Clone the complete plan to your dashboard for unlimited AI-generated notes, practice quizzes, and a personalised revision schedule.
Create Free Account