Student Login
AI & Data Science

Introduction to Machine Learning

In This Section, You Will Learn:

  • • What Machine Learning actually is
  • • Types of ML: Supervised vs Unsupervised
  • • Common ML algorithms explained simply
  • • Training, Testing, and Accuracy
  • • Building your first prediction model
  • • When to use ML (and when not to)

What is Machine Learning?

  • Machine Learning = Teaching computers to learn patterns from data and make predictions.
  • Think of it like:
  • • You show a child 100 pictures of cats and dogs
  • • The child learns what makes a cat vs a dog
  • • Now the child can identify new cats and dogs they've never seen
  • In Business Terms:
  • • Show the model 1000 customers who churned
  • • Model learns patterns of churning customers
  • • Model predicts which current customers might churn
  • The Magic: The model finds patterns humans can't see!

Types of Machine Learning

  • 1. Supervised Learning (Most Common):
  • • You have input data AND the correct answers
  • • Model learns to map inputs to outputs
  • • Example: Historical sales → Predict future sales
  • • Types: Regression (numbers), Classification (categories)
  • 2. Unsupervised Learning:
  • • You have data but NO correct answers
  • • Model finds hidden patterns itself
  • • Example: Group customers by behavior (clustering)
  • • Types: Clustering, Dimensionality Reduction
  • 3. Reinforcement Learning:
  • • Model learns by trial and error
  • • Gets rewards for good actions, penalties for bad
  • • Example: Game-playing AI, robotics
  • Start with Supervised Learning. It's the most practical for business.

Common Algorithms Explained Simply

  • Linear Regression:
  • • Predicts a number (continuous value)
  • • Example: Predict house price based on size
  • • Use when: Target is a number
  • Logistic Regression:
  • • Predicts a category (Yes/No, Class A/B/C)
  • • Example: Will customer buy? (Yes/No)
  • • Use when: Target is a category
  • Decision Trees:
  • • Makes decisions like a flowchart
  • • Easy to understand and explain
  • • Example: If age > 30 AND income > 50k, likely buyer
  • Random Forest:
  • • Many decision trees voting together
  • • More accurate than single tree
  • • Used in many real-world applications

Training, Testing, and Accuracy

  • The Process:
  • 1. Split your data: 80% training, 20% testing
  • 2. Train model on training data
  • 3. Test model on testing data (unseen by model)
  • 4. Measure accuracy
  • Why Split the Data?
  • • If you test on training data, model will cheat
  • • Testing on new data shows true performance
  • • This prevents 'overfitting'
  • Accuracy Metrics:
  • • Accuracy: % of correct predictions
  • • Precision: Of predicted positives, how many were right?
  • • Recall: Of actual positives, how many did we catch?
  • • 80%+ accuracy is usually good, but depends on problem

Building Your First Model (Code)

  • Using Scikit-Learn (The Standard Library):
  • from sklearn.model_selection import train_test_split
  • from sklearn.linear_model import LogisticRegression
  • from sklearn.metrics import accuracy_score
  • # Split data
  • X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)
  • # Create and train model
  • model = LogisticRegression()
  • model.fit(X_train, y_train)
  • # Make predictions
  • predictions = model.predict(X_test)
  • # Check accuracy
  • accuracy = accuracy_score(y_test, predictions)
  • print(f'Accuracy: {accuracy:.2f}')
  • Don't memorize this. Ask AI to write and explain it!

When to Use ML (And When Not To)

  • Use ML When:
  • • You have lots of historical data
  • • There's a pattern to learn
  • • Manual rules are too complex
  • • You need to make predictions at scale
  • Don't Use ML When:
  • • Simple rules work fine
  • • You don't have enough data
  • • You can't explain the prediction (sometimes important)
  • • The problem changes too often
  • Example:
  • • ML Good: Predicting which of 1M customers will churn
  • • ML Overkill: Deciding if someone is an adult (just check age >= 18)
⬅️ Previous Lesson Data Visualization Next Lesson ➡️ AI-Powered Data Analysis
Scroll to Top