Close Menu
    Trending
    • Why PDF Extraction Still Feels LikeHack
    • GenAI Will Fuel People’s Jobs, Not Replace Them. Here’s Why
    • Millions of websites to get ‘game-changing’ AI bot blocker
    • I Worked Through Labor, My Wedding and Burnout — For What?
    • Cloudflare will now block AI bots from crawling its clients’ websites by default
    • 🚗 Predicting Car Purchase Amounts with Neural Networks in Keras (with Code & Dataset) | by Smruti Ranjan Nayak | Jul, 2025
    • Futurwise: Unlock 25% Off Futurwise Today
    • 3D Printer Breaks Kickstarter Record, Raises Over $46M
    AIBS News
    • Home
    • Artificial Intelligence
    • Machine Learning
    • AI Technology
    • Data Science
    • More
      • Technology
      • Business
    AIBS News
    Home»Machine Learning»Vectorizing Logistic Regression: Teaching Machines to Think Faster | by Samuel Ekuma | Jan, 2025
    Machine Learning

    Vectorizing Logistic Regression: Teaching Machines to Think Faster | by Samuel Ekuma | Jan, 2025

    Team_AIBS NewsBy Team_AIBS NewsJanuary 11, 2025No Comments3 Mins Read
    Share Facebook Twitter Pinterest LinkedIn Tumblr Reddit Telegram Email
    Share
    Facebook Twitter LinkedIn Pinterest Email


    Have you ever ever questioned how computer systems make predictions? Whether or not it’s recognizing a canine in an image or recommending your subsequent Netflix binge, one key device is logistic regression. However, as datasets develop greater, processing one knowledge level at a time simply received’t work. That is the place vectorization saves the day.

    Let’s get into what vectorizing logistic regression is, and why it’s necessary.

    Logistic regression is a method to make predictions, particularly for yes-or-no questions:

    • Is that this image a canine?
    • Will it rain tomorrow?
    • Is that this electronic mail spam?

    The mannequin takes enter knowledge (X), combines it with weights (w) and bias (b), and spits out a chance utilizing the sigmoid operate:

    sigmoid equation

    the place:

    z = w^T. X + b

    σ(z) makes the outcome to be between 0 (no) and 1 (sure).

    Think about instructing a machine to categorise photos of canine. In case you have:

    • 10,000 photos
    • Every image has 100 options (like brightness or distinction)

    Processing one image at a time can be painfully sluggish. As a substitute, we will deal with all photos without delay utilizing matrix operations. Vectorization permits the pc to effectively compute predictions for a number of examples in parallel.

    For a single instance:

    z = w1⋅x1 + w2⋅x2 +…+ wn⋅xn + b

    For a number of examples:

    Z = w^T. X +b

    Right here:

    • X is a matrix with rows as options and columns as examples.
    • w^T is the transposed weights vector.
    • b is added to all examples without delay.
    1. Enter Knowledge (X):
      Consider X as a spreadsheet. Every column is an instance (e.g., an image), and every row is a characteristic (e.g., brightness).
    2. Weights and Bias (w and b):
      These are like knobs that regulate how a lot every characteristic issues for predicting whether or not the picture is a canine.
    3. Predictions (Z):
      Mix X, www, and b to get uncooked guesses for all examples without delay.
    4. Possibilities (σ(Z)):
      Use the sigmoid operate to transform uncooked guesses into chances (e.g., 0.8 = 80% likelihood it’s a canine).

    Right here’s a easy Python implementation of vectorized logistic regression:

    import numpy as np

    # Sigmoid operate
    def sigmoid(z):
    return 1 / (1 + np.exp(-z))

    # Knowledge:
    X = np.array([[0.5, 1.5, 2.5], [1.0, 2.0, 3.0]])
    Y = np.array([[1, 0, 1]]) # Precise labels (1 = canine, 0 = not a canine)

    # Initialize weights and bias
    w = np.zeros((2, 1)) # Two options, begin weights at 0
    b = 0
    n = 0.1 # Studying fee(n)
    epochs = 10 # Variety of coaching iterations

    # Coaching loop
    for epoch in vary(epochs):
    # Step 1: Compute Z
    Z = np.dot(w.T, X) + b

    # Step 2: Apply sigmoid
    Y_hat = sigmoid(Z)

    # Step 3: Compute value (how mistaken we're)
    value = -np.imply(Y * np.log(Y_hat) + (1 - Y) * np.log(1 - Y_hat))

    # Step 4: Calculate gradients (changes to weights and bias)
    dw = np.dot(X, (Y_hat - Y).T) / X.form[1]
    db = np.sum(Y_hat - Y) / X.form[1]

    # Step 5: Replace weights and bias
    w -= n * dw
    b -= n * db

    # Print the fee each epoch
    print(f"Epoch {epoch + 1}, Value: {value:.2f}")

    # Remaining weights and bias
    print(" Weights:", w)
    print(" Bias:", b)

    1. Vectorization Saves Time and Computation Useful resource:
      As a substitute of processing one instance at a time, you course of many without delay.
    2. The Math Is Easy:
      It’s all about combining enter options (X), weights (w), and bias (b) to make predictions.
    3. Logistic Regression Is Highly effective:
      Regardless that it’s easy, it’s the muse for extra complicated fashions in machine studying.

    Now that you simply’ve understood vectorized logistic regression, the following step is to going deeper into:

    • Backpropagation: How the machine adjusts its weights.
    • Multi-class Logistic Regression: Predicting greater than two classes.

    Keep tuned for extra insights on how machines study! 🙂



    Source link

    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
    Previous ArticleRoborock Saros Z70, SwitchBot, and More
    Next Article Linearizing Llama. Speeding Up Llama: A Hybrid Approach to… | by Shitanshu Bhushan | Jan, 2025
    Team_AIBS News
    • Website

    Related Posts

    Machine Learning

    Why PDF Extraction Still Feels LikeHack

    July 1, 2025
    Machine Learning

    🚗 Predicting Car Purchase Amounts with Neural Networks in Keras (with Code & Dataset) | by Smruti Ranjan Nayak | Jul, 2025

    July 1, 2025
    Machine Learning

    Reinforcement Learning in the Age of Modern AI | by @pramodchandrayan | Jul, 2025

    July 1, 2025
    Add A Comment
    Leave A Reply Cancel Reply

    Top Posts

    Why PDF Extraction Still Feels LikeHack

    July 1, 2025

    I Tried Buying a Car Through Amazon: Here Are the Pros, Cons

    December 10, 2024

    Amazon and eBay to pay ‘fair share’ for e-waste recycling

    December 10, 2024

    Artificial Intelligence Concerns & Predictions For 2025

    December 10, 2024

    Barbara Corcoran: Entrepreneurs Must ‘Embrace Change’

    December 10, 2024
    Categories
    • AI Technology
    • Artificial Intelligence
    • Business
    • Data Science
    • Machine Learning
    • Technology
    Most Popular

    The Future of AI in Enhancing Virtual Intimacy

    March 19, 2025

    Report: $15B OpenAI Data Center in Texas Will House up to 400,000 Blackwells

    May 21, 2025

    3 Unconventional Productivity Tips to Stimulate Creative Thinking

    December 16, 2024
    Our Picks

    Why PDF Extraction Still Feels LikeHack

    July 1, 2025

    GenAI Will Fuel People’s Jobs, Not Replace Them. Here’s Why

    July 1, 2025

    Millions of websites to get ‘game-changing’ AI bot blocker

    July 1, 2025
    Categories
    • AI Technology
    • Artificial Intelligence
    • Business
    • Data Science
    • Machine Learning
    • Technology
    • Privacy Policy
    • Disclaimer
    • Terms and Conditions
    • About us
    • Contact us
    Copyright © 2024 Aibsnews.comAll Rights Reserved.

    Type above and press Enter to search. Press Esc to cancel.