Simple Machine Learning for Programmers: Beginner's Intro to Using Machine Learning, Deep Learning, and Artificial Intelligence for Practical Applications ... AI: Deep Learning and Machine Learning) by Programmer Lazy
Author:Programmer, Lazy [Programmer, Lazy]
Language: eng
Format: epub
Published: 2018-08-19T16:00:00+00:00
As usual, when we represent this in code, they are just arrays of numbers.
The arrays don’t know what those numbers represent, since the “meaning” of each column is purely conceptual.
What does the actual code look like?
Lucky for us, it actually looks exactly the same as before.
First, we instantiate the model. Let’s suppose we’re using linear regression.
model = LinearRegression()
Then, we train the model, by calling fit and passing in X and Y.
model.fit(X, Y)
We can also make new predictions by calling the predict function.
predictions = model.predict(X)
Finally, we can evaluate the model by calling the score function.
model.score(X, Y)
One minor difference with regression is that the score function no longer returns the accuracy, which only makes sense when we’re doing classification.
That’s because the accuracy is just # correct / # total.
That makes sense when we have labels, because if you guess the right label, then you’re correct, otherwise, you’re not.
But for regression, that doesn’t make sense.
Suppose the price of a house is $1 million, and we predict $1 million+1.
Does that mean we’re wrong? No. In fact, intuitively we know this prediction is pretty good.
It’s not “correct” since $1 million != $1 million + 1. So accuracy may not be the best evaluation metric.
In general, one way to measure the performance of a regression model is to use the mean squared error (MSE).
The mean squared error is the average of the squared difference between each prediction and its corresponding target.
However, the MSE is not what is returned by the score function.
Why?
Let’s think about why we might not want a score function to return the mean squared error.
Consider house prices again. These are numbers that are going to range from a few hundred thousand, to millions.
Now think about grades. These are numbers that are going to range from 0 to 100.
Magnitude matters.
You don’t really care if a house costs $1 million, and you guess $1 million+100. That’s still a pretty good prediction.
But, if you’re predicting grades, then a difference of 100 in the prediction is huge. That’s as large as the entire range of possible values.
What we care about is the relative difference between the squared error and the range of possible values.
Instead, we use a measurement called the R2 (“R-squared”).
If you want to read more about it, I would suggest Wikipedia - but I promised you no math in this book and I’m sticking to it.
Instead, I’ll tell you how to interpret the R2 .
Generally, it’s going to be a number less than or equal to 1.
1 means your prediction is perfect. There is no difference between your prediction and the targets.
0 means your model is doing the dumbest thing possible - just predicting the average value of the targets.
For example, if your targets are [1, 2, 3, 4, 5], that means you’re predicting 3 every time.
We say this is “dumb” because it doesn’t consider the input data at all.
It is possible for your R2 to be negative. In this case, your model performs worse than simply predicting the mean target, which means your model is pretty bad.
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Computer Vision & Pattern Recognition | Expert Systems |
Intelligence & Semantics | Machine Theory |
Natural Language Processing | Neural Networks |
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(8292)
Test-Driven Development with Java by Alan Mellor(6655)
Data Augmentation with Python by Duc Haba(6561)
Principles of Data Fabric by Sonia Mezzetta(6321)
Learn Blender Simulations the Right Way by Stephen Pearson(6208)
Microservices with Spring Boot 3 and Spring Cloud by Magnus Larsson(6083)
Hadoop in Practice by Alex Holmes(5958)
Jquery UI in Action : Master the concepts Of Jquery UI: A Step By Step Approach by ANMOL GOYAL(5806)
RPA Solution Architect's Handbook by Sachin Sahgal(5474)
Big Data Analysis with Python by Ivan Marin(5327)
The Infinite Retina by Robert Scoble Irena Cronin(5174)
Life 3.0: Being Human in the Age of Artificial Intelligence by Tegmark Max(5139)
Pretrain Vision and Large Language Models in Python by Emily Webber(4288)
Infrastructure as Code for Beginners by Russ McKendrick(4049)
Functional Programming in JavaScript by Mantyla Dan(4037)
The Age of Surveillance Capitalism by Shoshana Zuboff(3943)
WordPress Plugin Development Cookbook by Yannick Lefebvre(3761)
Embracing Microservices Design by Ovais Mehboob Ahmed Khan Nabil Siddiqui and Timothy Oleson(3565)
Applied Machine Learning for Healthcare and Life Sciences Using AWS by Ujjwal Ratan(3539)
