• About
  • Advertise
  • Privacy & Policy
  • Contact
Saturday, January 3, 2026
  • Login
  • Home
    • Home – Layout 1
    • Home – Layout 2
    • Home – Layout 3
    • Home – Layout 4
    • Home – Layout 5
    • Home – Layout 6
  • News
    • All
    • Business
    • Politics
    • Science
    • World
    Hillary Clinton in white pantsuit for Trump inauguration

    Hillary Clinton in white pantsuit for Trump inauguration

    Amazon has 143 billion reasons to keep adding more perks to Prime

    Amazon has 143 billion reasons to keep adding more perks to Prime

    Shooting More than 40 Years of New York’s Halloween Parade

    Shooting More than 40 Years of New York’s Halloween Parade

    These Are the 5 Big Tech Stories to Watch in 2017

    These Are the 5 Big Tech Stories to Watch in 2017

    Why Millennials Need to Save Twice as Much as Boomers Did

    Why Millennials Need to Save Twice as Much as Boomers Did

    Doctors take inspiration from online dating to build organ transplant AI

    Doctors take inspiration from online dating to build organ transplant AI

    Trending Tags

    • Trump Inauguration
    • United Stated
    • White House
    • Market Stories
    • Election Results
  • Tech
    • All
    • Apps
    • Gadget
    • Mobile
    • Startup
    The Legend of Zelda: Breath of the Wild gameplay on the Nintendo Switch

    The Legend of Zelda: Breath of the Wild gameplay on the Nintendo Switch

    Shadow Tactics: Blades of the Shogun Review

    Shadow Tactics: Blades of the Shogun Review

    macOS Sierra review: Mac users get a modest update this year

    macOS Sierra review: Mac users get a modest update this year

    Hands on: Samsung Galaxy A5 2017 review

    Hands on: Samsung Galaxy A5 2017 review

    The Last Guardian Playstation 4 Game review

    The Last Guardian Playstation 4 Game review

    These Are the 5 Big Tech Stories to Watch in 2017

    These Are the 5 Big Tech Stories to Watch in 2017

    Trending Tags

    • Nintendo Switch
    • CES 2017
    • Playstation 4 Pro
    • Mark Zuckerberg
  • Entertainment
    • All
    • Gaming
    • Movie
    • Music
    • Sports
    The Legend of Zelda: Breath of the Wild gameplay on the Nintendo Switch

    The Legend of Zelda: Breath of the Wild gameplay on the Nintendo Switch

    macOS Sierra review: Mac users get a modest update this year

    macOS Sierra review: Mac users get a modest update this year

    Hands on: Samsung Galaxy A5 2017 review

    Hands on: Samsung Galaxy A5 2017 review

    Heroes of the Storm Global Championship 2017 starts tomorrow, here’s what you need to know

    Heroes of the Storm Global Championship 2017 starts tomorrow, here’s what you need to know

    Harnessing the power of VR with Power Rangers and Snapdragon 835

    Harnessing the power of VR with Power Rangers and Snapdragon 835

    So you want to be a startup investor? Here are things you should know

    So you want to be a startup investor? Here are things you should know

  • Lifestyle
    • All
    • Fashion
    • Food
    • Health
    • Travel
    Shooting More than 40 Years of New York’s Halloween Parade

    Shooting More than 40 Years of New York’s Halloween Parade

    Heroes of the Storm Global Championship 2017 starts tomorrow, here’s what you need to know

    Heroes of the Storm Global Championship 2017 starts tomorrow, here’s what you need to know

    Why Millennials Need to Save Twice as Much as Boomers Did

    Why Millennials Need to Save Twice as Much as Boomers Did

    Doctors take inspiration from online dating to build organ transplant AI

    Doctors take inspiration from online dating to build organ transplant AI

    How couples can solve lighting disagreements for good

    How couples can solve lighting disagreements for good

    Ducati launch: Lorenzo and Dovizioso’s Desmosedici

    Ducati launch: Lorenzo and Dovizioso’s Desmosedici

    Trending Tags

    • Golden Globes
    • Game of Thrones
    • MotoGP 2017
    • eSports
    • Fashion Week
  • Review
    The Legend of Zelda: Breath of the Wild gameplay on the Nintendo Switch

    The Legend of Zelda: Breath of the Wild gameplay on the Nintendo Switch

    Shadow Tactics: Blades of the Shogun Review

    Shadow Tactics: Blades of the Shogun Review

    macOS Sierra review: Mac users get a modest update this year

    macOS Sierra review: Mac users get a modest update this year

    Hands on: Samsung Galaxy A5 2017 review

    Hands on: Samsung Galaxy A5 2017 review

    The Last Guardian Playstation 4 Game review

    The Last Guardian Playstation 4 Game review

    Intel Core i7-7700K ‘Kaby Lake’ review

    Intel Core i7-7700K ‘Kaby Lake’ review

No Result
View All Result
Ai News
Advertisement
  • Home
    • Home – Layout 1
    • Home – Layout 2
    • Home – Layout 3
    • Home – Layout 4
    • Home – Layout 5
    • Home – Layout 6
  • News
    • All
    • Business
    • Politics
    • Science
    • World
    Hillary Clinton in white pantsuit for Trump inauguration

    Hillary Clinton in white pantsuit for Trump inauguration

    Amazon has 143 billion reasons to keep adding more perks to Prime

    Amazon has 143 billion reasons to keep adding more perks to Prime

    Shooting More than 40 Years of New York’s Halloween Parade

    Shooting More than 40 Years of New York’s Halloween Parade

    These Are the 5 Big Tech Stories to Watch in 2017

    These Are the 5 Big Tech Stories to Watch in 2017

    Why Millennials Need to Save Twice as Much as Boomers Did

    Why Millennials Need to Save Twice as Much as Boomers Did

    Doctors take inspiration from online dating to build organ transplant AI

    Doctors take inspiration from online dating to build organ transplant AI

    Trending Tags

    • Trump Inauguration
    • United Stated
    • White House
    • Market Stories
    • Election Results
  • Tech
    • All
    • Apps
    • Gadget
    • Mobile
    • Startup
    The Legend of Zelda: Breath of the Wild gameplay on the Nintendo Switch

    The Legend of Zelda: Breath of the Wild gameplay on the Nintendo Switch

    Shadow Tactics: Blades of the Shogun Review

    Shadow Tactics: Blades of the Shogun Review

    macOS Sierra review: Mac users get a modest update this year

    macOS Sierra review: Mac users get a modest update this year

    Hands on: Samsung Galaxy A5 2017 review

    Hands on: Samsung Galaxy A5 2017 review

    The Last Guardian Playstation 4 Game review

    The Last Guardian Playstation 4 Game review

    These Are the 5 Big Tech Stories to Watch in 2017

    These Are the 5 Big Tech Stories to Watch in 2017

    Trending Tags

    • Nintendo Switch
    • CES 2017
    • Playstation 4 Pro
    • Mark Zuckerberg
  • Entertainment
    • All
    • Gaming
    • Movie
    • Music
    • Sports
    The Legend of Zelda: Breath of the Wild gameplay on the Nintendo Switch

    The Legend of Zelda: Breath of the Wild gameplay on the Nintendo Switch

    macOS Sierra review: Mac users get a modest update this year

    macOS Sierra review: Mac users get a modest update this year

    Hands on: Samsung Galaxy A5 2017 review

    Hands on: Samsung Galaxy A5 2017 review

    Heroes of the Storm Global Championship 2017 starts tomorrow, here’s what you need to know

    Heroes of the Storm Global Championship 2017 starts tomorrow, here’s what you need to know

    Harnessing the power of VR with Power Rangers and Snapdragon 835

    Harnessing the power of VR with Power Rangers and Snapdragon 835

    So you want to be a startup investor? Here are things you should know

    So you want to be a startup investor? Here are things you should know

  • Lifestyle
    • All
    • Fashion
    • Food
    • Health
    • Travel
    Shooting More than 40 Years of New York’s Halloween Parade

    Shooting More than 40 Years of New York’s Halloween Parade

    Heroes of the Storm Global Championship 2017 starts tomorrow, here’s what you need to know

    Heroes of the Storm Global Championship 2017 starts tomorrow, here’s what you need to know

    Why Millennials Need to Save Twice as Much as Boomers Did

    Why Millennials Need to Save Twice as Much as Boomers Did

    Doctors take inspiration from online dating to build organ transplant AI

    Doctors take inspiration from online dating to build organ transplant AI

    How couples can solve lighting disagreements for good

    How couples can solve lighting disagreements for good

    Ducati launch: Lorenzo and Dovizioso’s Desmosedici

    Ducati launch: Lorenzo and Dovizioso’s Desmosedici

    Trending Tags

    • Golden Globes
    • Game of Thrones
    • MotoGP 2017
    • eSports
    • Fashion Week
  • Review
    The Legend of Zelda: Breath of the Wild gameplay on the Nintendo Switch

    The Legend of Zelda: Breath of the Wild gameplay on the Nintendo Switch

    Shadow Tactics: Blades of the Shogun Review

    Shadow Tactics: Blades of the Shogun Review

    macOS Sierra review: Mac users get a modest update this year

    macOS Sierra review: Mac users get a modest update this year

    Hands on: Samsung Galaxy A5 2017 review

    Hands on: Samsung Galaxy A5 2017 review

    The Last Guardian Playstation 4 Game review

    The Last Guardian Playstation 4 Game review

    Intel Core i7-7700K ‘Kaby Lake’ review

    Intel Core i7-7700K ‘Kaby Lake’ review

No Result
View All Result
Ai News
No Result
View All Result
Home Machine Learning

The Machine Learning “Advent Calendar” Day 12: Logistic Regression in Excel

AiNEWS2025 by AiNEWS2025
2025-12-13
in Machine Learning
0
The Machine Learning “Advent Calendar” Day 12: Logistic Regression in Excel
0
SHARES
0
VIEWS
Share on FacebookShare on Twitter


Today’s model is Logistic Regression.

If you already know this model, here is a question for you:

Is Logistic Regression a regressor or a classifier?

Well, this question is exactly like: Is a tomato a fruit or a vegetable?

From a botanist’s viewpoint, a tomato is a fruit, because they look at structure: seeds, flowers, plant biology.

From a cook’s viewpoint, a tomato is a vegetable, because they look at taste, how it is used in a recipe, whether it goes in a salad or a dessert.

The same object, two valid answers, because the point of view is different.

Logistic Regression is exactly like that.

  • In the Statistical / GLM perspective, it is a regression. And there is not the concept of “classification” in this framework anyway. There are gamma regression, logistic regression, Poisson regression…
  • In the machine learning perspective, it is used for classification. So it is a classifier.

We will come back to this later.

For now, one thing is sure:

Logistic Regression is very well adapted when the target variable is binary, and usually y is coded as 0 or 1.

But…

What is a classifier for a weight-based model?

So, y can be 0 or 1.

0 or 1, they are numbers, right?

So we can just consider y as continuous!

Yes, y = a x + b, with y = 0 or 1.

Why not?

Now, you may ask: why this question, now? Why it was not asked before.

Well, for distance-based and tree-based models, a categorical y is truly categorical.

When y is categorical, like red, blue, green, or simply 0 and 1:

  • In K-NN, you classify by looking at neighbors of each class.
  • In centroid models, you compare with the centroid of each class.
  • In a decision tree, you compute class proportions at each node.

In all these models:

Class labels are not numbers.
They are categories.
The algorithms never treat them as values.

So classification is natural and immediate.

But for weight-based models, things work differently.

In a weight-based model, we always compute something like:

y = a x + b

or, later, a more complex function with coefficients.

This means:

The model works with numbers everywhere.

So here is the key idea:

If the model does regression, then this same model can be used for binary classification.

Yes, we can use linear regression for binary classification!

Since binary labels are 0 and 1, they are already numeric.

And in this special case: we can apply Ordinary Least Squares (OLS) directly on y = 0 and y = 1.

The model will fit a line, and we can use the same closed-form formula, as we can see below.

Logistic Regression in Excel – all images by author

We can do the same gradient descent, and it will perfectly work:

And then, to obtain the final class prediction, we simply choose a threshold.
It is usually 0.5 (or 50 percent), but depending on how strict you want to be, you can pick another value.

  • If the predicted y≥0.5, predict class 1
  • Otherwise, class 0

This is a classifier.

And because the model produces a numeric output, we can even identify the point where: y=0.5.

This value of x defines the decision frontier.

In the previous example, this happens at x=9.
At this threshold, we already saw one misclassification.

But a problem appears as soon as we introduce a point with a large value of x.

For example, suppose we add a point with: x= 50 and y = 1.

Because linear regression tries to fit a straight line through all the data, this single large value of x pulls the line upward.
The decision frontier shifts from x= to approximately x=12.

And now, with this new boundary, we end up with two misclassifications.

This illustrates the main issue:

A linear regression used as a classifier is extremely sensitive to extreme values of x. The decision frontier moves dramatically, and the classification becomes unstable.

This is one of the reasons we need a model that does not behave linearly forever. A model that stays between 0 and 1, even when x becomes very large.

And this is exactly what the logistic function will give us.

How Logistic Regression works

We start with : ax + b, just like the linear regression.

Then we apply one function called sigmoid, or logistic function.

As we can see in the screenshot below, the value of p is then between 0 and 1, so this is perfect.

  • p(x) is the predicted probability that y = 1
  • 1 − p(x) is the predicted probability that y = 0

For classification, we can simply say:

  • If p(x) ≥ 0.5, predict class 1
  • Otherwise, predict class 0

From likelihood to log-loss

Now, the OLS Linear Regression tries to minimize the MSE (Mean Squared Error).

Logistic regression for a binary target uses the Bernoulli likelihood. For each observation i:

  • If yᵢ = 1, the probability of the data point is pᵢ
  • If yᵢ = 0, the probability of the data point is 1 − pᵢ

For the whole dataset, the likelihood is the product over all i. In practice, we take the logarithm, which turns the product into a sum.

In the GLM perspective, we try to maximize this log likelihood.

In the machine learning perspective, we define the loss as the negative log likelihood and we minimize it. This gives the usual log-loss.

And it is equivalent. We will not do the demonstration here

Gradient Descent for Logistic Regression

Principle

Just as we did for Linear Regression, we can also use Gradient Descent here. The idea is always the same:

  1. Start from some initial values of a and b.
  2. Compute the loss and its gradient (derivatives) with respect to a and b.
  3. Move a and b a little bit in the direction that reduces the loss.
  4. Repeat.

Nothing mysterious.
Just the same mechanical process as before.

Step 1. Gradient Calculation

For logistic regression, the gradients of the average log-loss follow a very simple structure.

This is simply the average residual.

We will just give the result below, for the formula that we can implement in Excel. As you can see, it is quite simple at the end, even if the log-loss formula can be complex at first glance.

Excel can compute these two quantities with straightforward SUMPRODUCT formulas.

Step 2. Parameter Update

Once the gradients are known, we update the parameters.

This update step is repeated at each iteration.
And iteration after iteration, the loss goes down, and the parameters converge to the optimal values.

We now have the whole picture.
You have seen the model, the loss, the gradients, and the parameter updates.
And with the detailed view of each iteration in Excel, you can actually play with the model: change a value, watch the curve move, and see the loss decrease step by step.

It is surprisingly satisfying to observe how everything fits together so clearly.

What about multiclass classification?

For distance-based and tree-based models:

No issue at all.
They naturally handle multiple classes because they never interpret the labels as numbers.

But for weight-based models?

Here we hit a problem.

If we write numbers for the class: 1, 2, 3, etc.

Then the model will interpret these numbers as real numeric values.
Which leads to problems:

  • the model thinks class 3 is “bigger” than class 1
  • the midpoint between class 1 and class 3 is class 2
  • distances between classes become meaningful

But none of this is true in classification.

So:

For weight-based models, we cannot just use y = 1, 2, 3 for multiclass classification.

This encoding is incorrect.

We will see later how to fix this.

Conclusion

Starting from a simple binary dataset, we saw how a weight-based model can act as a classifier, why linear regression quickly reaches its limits, and how the logistic function solves these problems by keeping predictions between 0 and 1.

Then, by expressing the model through likelihood and log-loss, we obtained a formulation that is both mathematically sound and easy to implement.
And once everything is placed in Excel, the entire learning process becomes visible: the probabilities, the loss, the gradients, the updates, and finally the convergence of the parameters.

With the detailed iteration table, you can actually see how the model improves step by step.
You can change a value, adjust the learning rate, or add a point, and instantly observe how the curve and the loss react.
This is the real value of doing machine learning in a spreadsheet: nothing is hidden, and every calculation is transparent.

By building logistic regression this way, you not only understand the model, you understand why it is trained.
And this intuition will stay with you as we move to more advanced models later in the Advent Calendar.

Source link

#Machine #Learning #Advent #Calendar #Day #Logistic #Regression #Excel

Tags: artificial intelligencedata sciencemachine learningStatistics
Previous Post

How OpenAI is using GPT-5 Codex to improve the AI tool itself

Next Post

How cloud infrastructure shapes the modern Diablo experience 

AiNEWS2025

AiNEWS2025

Next Post
How cloud infrastructure shapes the modern Diablo experience 

How cloud infrastructure shapes the modern Diablo experience 

Stay Connected test

  • 23.9k Followers
  • 99 Subscribers
  • Trending
  • Comments
  • Latest
A tiny new open source AI model performs as well as powerful big ones

A tiny new open source AI model performs as well as powerful big ones

0
Water Cooler Small Talk: The Birthday Paradox 🎂🎉 | by Maria Mouschoutzi, PhD | Sep, 2024

Water Cooler Small Talk: The Birthday Paradox 🎂🎉 | by Maria Mouschoutzi, PhD | Sep, 2024

0
Ghost of Yōtei: The acclaimed Ghost of Tsushima is getting a sequel

Ghost of Yōtei: The acclaimed Ghost of Tsushima is getting a sequel

0
Best Headphones for Working Out (2024): Bose, Shokz, JLab

Best Headphones for Working Out (2024): Bose, Shokz, JLab

0
Off-Beat Careers That Are the Future Of Data

Off-Beat Careers That Are the Future Of Data

2026-01-03
No, Grok can’t really “apologize” for posting non-consensual sexual images

No, Grok can’t really “apologize” for posting non-consensual sexual images

2026-01-03
Billion-dollar Bitcoin hacker Ilya Lichtenstein thanks Trump for early prison release

Billion-dollar Bitcoin hacker Ilya Lichtenstein thanks Trump for early prison release

2026-01-03
NASA Reportedly Shutting Down Its Largest Library, Throwing Materials Away

NASA Reportedly Shutting Down Its Largest Library, Throwing Materials Away

2026-01-03

Recent News

Off-Beat Careers That Are the Future Of Data

Off-Beat Careers That Are the Future Of Data

2026-01-03
No, Grok can’t really “apologize” for posting non-consensual sexual images

No, Grok can’t really “apologize” for posting non-consensual sexual images

2026-01-03
Billion-dollar Bitcoin hacker Ilya Lichtenstein thanks Trump for early prison release

Billion-dollar Bitcoin hacker Ilya Lichtenstein thanks Trump for early prison release

2026-01-03
NASA Reportedly Shutting Down Its Largest Library, Throwing Materials Away

NASA Reportedly Shutting Down Its Largest Library, Throwing Materials Away

2026-01-03
Footer logo

We bring you the best Premium WordPress Themes that perfect for news, magazine, personal blog, etc. Check our landing page for details.

Follow Us

Browse by Category

  • AI & Cloud Computing
  • AI & Cybersecurity
  • AI & Sentiment Analysis
  • AI Applications
  • AI Ethics
  • AI Future Predictions
  • AI in Education
  • AI in Fintech
  • AI in Gaming
  • AI in Healthcare
  • AI in Startups
  • AI Innovations
  • AI News
  • AI Research
  • AI Tools & Automation
  • Apps
  • AR/VR & AI
  • Business
  • Deep Learning
  • Emerging Technologies
  • Entertainment
  • Fashion
  • Food
  • Gadget
  • Gaming
  • Health
  • Lifestyle
  • Machine Learning
  • Mobile
  • Movie
  • Music
  • News
  • Politics
  • Review
  • Robotics & Smart Systems
  • Science
  • Sports
  • Startup
  • Tech
  • Travel
  • World

Recent News

Off-Beat Careers That Are the Future Of Data

Off-Beat Careers That Are the Future Of Data

2026-01-03
No, Grok can’t really “apologize” for posting non-consensual sexual images

No, Grok can’t really “apologize” for posting non-consensual sexual images

2026-01-03
  • About
  • Advertise
  • Privacy & Policy
  • Contact

© 2026 JNews - Premium WordPress news & magazine theme by Jegtheme.

Welcome Back!

Login to your account below

Forgotten Password?

Retrieve your password

Please enter your username or email address to reset your password.

Log In
No Result
View All Result

© 2026 JNews - Premium WordPress news & magazine theme by Jegtheme.