How to program the Best Fit Slope - Practical Machine Learning Tutorial with Python p.8

preview_player
Показать описание
Welcome to the 8th part of our machine learning regression tutorial within our Machine Learning with Python tutorial series. Where we left off, we had just realized that we needed to replicate some non-trivial algorithms into Python code in an attempt to calculate a best-fit line for a given dataset.

Before we embark on that, why are we going to bother with all of this? Linear Regression is basically the brick to the machine learning building. It is used in almost every single major machine learning algorithm, so an understanding of it will help you to get the foundation for most major machine learning algorithms. For the enthusiastic among us, understanding linear regression and general linear algebra is the first step towards writing your own custom machine learning algorithms and branching out into the bleeding edge of machine learning, using what ever the best processing is at the time. As processing improves and hardware architecture changes, the methodologies used for machine learning also change. The more recent rise in neural networks has had much to do with general purpose graphics processing units. Ever wonder what's at the heart of an artificial neural network? You guessed it: linear regression.

Рекомендации по теме
Комментарии
Автор

Children, when you see sentdex struggle in 9:11, always remember... Writing too complicated math expression is no no.
Use the following breaks:
def best_fit_slope(xs, ys):
numerator = (np.mean(xs)*np.mean(ys)) - np.mean(xs*ys)
denominator = np.mean(xs)**2 - np.mean(xs**2)
return numerator/denominator

Love you sentdex! keep up the good work!

EranM
Автор

I like your tutorials but kinda feel you wasted a lot of time on this one explaining how to manage parentheses and stuff, while you rushed through much more complicated things in the previous ones.

guryo
Автор

Like nruv after 7 years still the best explanation with jokes and stuff you dhould be a teacher in Harvard

Cubing-Iz-EZ
Автор

SciPy has a function for best fit. Check linregress in scipy.stats
from scipy.stats import linregress
slope, intercept, r_value, p_value, std_err = linregress(xs, ys)

JCRMatos
Автор

Doesn't ^ do a bitwise XOR operation?

ErikBoesen
Автор

Complete explanation of "Slope of the best fit line" and the "squared error" is in below tutorials

ranaify
Автор

your tutorials have helped a production engineer like myself understand and apply machine learning! thanks!

financewithrishabh
Автор

Your my Hero sentdex ! all you need is a costume, to put super in front of that Hero!, loving this series! so interesting!!! hope this series has lots of video's!!! Machine learning rocks!!!

happydays
Автор

mean(xs)*mean(xs) will cause the mean(xs) to be evaluated twice. Use mean(xs)**2 as its more efficient.

ShantanuBhadoria
Автор

Hello, my question is: given your definition of best_fit_slope(xs, ys) at 10:12. How many times the value of mean(xs) gets computed? Three times? Wouldn't it worth it to introduce a temporary variable?

pentekimi
Автор

factor mean(xs) out and the calculation will be faster and easier to read. ms = mean(xs), then use ms in place of mean(xs)

grahamastor
Автор

please made a tutorial on multivariate linear regression

zahidulislam
Автор

is this explanation how Linear Regression works ....Do we handly write the given function LinearRegression used in the previous videos ?

vladantrajkovski
Автор

Why not use the numpy mean method instead of an 'extra' import from statistics?

janwillemvanholst
Автор

Hi great tutorials, just wondering what type of Linear Regression is this in python because I thought in order to do Linear Regression you need modules like sklearn so can someone explain how I apply this to a dataset from the internet.

meicalpinghu
Автор

You are doing a great job brother. You must be getting job offers init? If yes then from which companies, if you don't mind sharing. Thank you so much for these precious tuts.

MeetYourArchitect
Автор

Would you please point out where is the mistake on the stock prediction that you said was fixed (the dates are not in the future but it predicts or take the prices of the existing dates).
Kind regards.

cryptomustache
Автор

You are using statistics library for 'mean', and before you used math for math.ceil. But both functions are available with numpy. Is it just a matter of preference or there are some hidden reasons behind it?

samirGGM
Автор

you cant confuse me with pemdas, im still gonna use BODMAS
hahah

changumangu
Автор

I know how to get coefficients in simple linear regression but I do not know how to get the coefficients or weights without using sklearn or other libraries! I cant find resources too! How can I write my own functions to do this?

imdadulhaque