Gen AI Developer Week 2— Day 1
We’ll go over the fundamental ideas of machine learning (ML) today, including its various forms and important terms. Recognize the definition of machine learning and its uses.Discover the distinctions between reinforcement learning, supervised learning, and unsupervised learning.
Examine the two main supervised algorithms, k-Nearest Neighbors (k-NN) and linear regression.
What is Machine Learning ?
A branch of artificial intelligence called machine learning uses data to teach machines how to perform efficiently without explicitly programming them.
Few Applications of Machine Learning (ML)
1. Image Recognition — Face Based Attendance System
2. Spam Email Filtering — Gmail Spam Email Filtering
3. Rcommender Systems — (Amazon & Netflix)
Types of Machine Learning
1. Supervised Learning — (Learns from Labelled Data)
The model learns from labeled data. For example, predict house values based on factors such as size and location.
2. Unsupervised Learning — (Learns from Unlabelled Data)
The model recognizes patterns in unlabeled data.For example, clients can be grouped depending on their purchase habits.
3. Reinforcement Learning — (Learns from its Surroundings)
The model learns by interacting with its surroundings and getting input (rewards or punishments). Example: Teaching a robot to walk.
Key Algorithms for Supervised Learning
1. Linear Regression
Predicts a continuous value
Equation: 𝑦=𝑚𝑥+𝑏
y: Target (dependent variable)
x: Features (independent variables)
m: Slope (weights)
b: Intercept (bias)
2. k-Nearest Neighbors (k-NN)
A classification procedure that uses the majority label of the closest 𝑘 data points to determine a label. performs well with smaller datasets that have fewer characteristics.
Explore the Scikit-learn Library
# Scikit-learn, a powerful library for machine learning
pip install scikit-learn
Linear Regression Intuition
# Plot a simple line 𝑦=2𝑥+3 using matplotlib
import numpy as np
import matplotlib.pyplot as plt
x = np.linspace(0, 10, 100)
y = 2 * x + 3
#Plotting
plt.plot(x,y label='y=2x+3')
plt.xlabel('x')
plt.ylabel('y')
plt.title('Linear Regression Line')
plt.legend()
plt.show()
Supervised Learning Example
from sklearn.datasets import load_diabetes
data = load_diabetes()
# Features and Target Separation based on the dataset
x = data.data
y = data.target
print("Feature Names:", data.feature_names)
print("First 5 rows of features:\n", x[:5])
print("First 5 target values:", y[:5])
Deliverables for Today:
1. Summary of ML Types.
2. Code for plotting a linear regression line.
3. Output from loading and exploring a dataset from sklearn.
Happy Learning!😊.. For any questions or support, feel free to message me on LinkedIn.