Linear Regression Python Sklearn [FROM SCRATCH]

Python Maratón
Python Maratón
82.2 هزار بار بازدید - 5 سال پیش - Descargar Código:
Descargar Código: Patreon: pythonmaraton

Join Patreon: Patreon: pythonmaraton
^Downloadable code & more!

linear regression python sklearn. In this video we will learn how to use SkLearn for linear regression in Python. You can follow along with this linear regression sklearn python example. The linear regression in python will be done using SKlearn. The first thing we need to do is import. We will import a pydataset to use in this example. And let’s get Pandas and numpy. Next we import the thing we will need from sklearn. LinearRegression from the linear_model package, train test split, and lastly let’s get matplotlib in there so we can visualize this model. First of all, let’s get our data. We will be using the Pima women data. If you ever want to see details about a dataset you can enter in the keyword. Let’s check this data to see if it is approximately linear. In this example we will see if tricep skin fold measurements can predict body mass index (BMI). We can use the pandas plotting capabilities, with kind as scatter. There is the plot. This looks decently linear. So we will proceed with the model. Now we are going to do a test train split. We are doing supervised learning. Basically we create the model using only the training data, and then we use that model to see how well it predicts the testing data. Let’s plot the train test split so you can see what I mean. Everything in red will be used to create our line, and that line will be tested against the green data. Okay, so now let’s actually create the linear mode. LR.fit() and we will plug in X_train and y_train.  We reshape X_train because the input must be two dimensional. So .reshape(-1,1) will work just fine. Now let’s use this model to predict on the test data. We will plot that against a scatter plot of the actual test data. Here it is. The line is the model prediction and the green points are the actual data. It seems to do a decent job at following the overall trend. There may be some outliers.  Suppose we want to see how the model will predict a specific skin fold measurement, say 50. Let’s plug that in and see. Alright, now we will score the model using Sklearn’s built-in score function. and it came out at .39… The max it could get would be a 1. I want you to think about what that score means and leave what you think in the comments below. Do you think this is a good model?  So there you have it, that is how you can use python’s Sklearn to create a linear regression model. Please check out some of my other python videos and please subscribe for more python content. :D This is a Python anaconda tutorial for help with coding, programming,  or computer science. These are short python videos dedicated to troubleshooting python problems and learning Python syntax. For more videos see Python Help playlist by Rylan Fowers.

0:00 Intro
0:10 Preparing Data
1:36 Train Test Split
3:09 Training
5:13 Predicting
5:47 Scoring


✅Subscribe: @pythonmaraton

📺Channel: @pythonmaraton


🎵Theme Music: https://www.bensound.com/royalty-free...

View the documentation: https://scikit-learn.org/stable/modul...


#PythonMarathon #LearnPython #PythonTutorial Learn Python:
Python Book (English): https://amzn.to/3HcwgLd
Libro de Python (Español): https://amzn.to/47woAhQ
Affordable Laptop: https://amzn.to/48L30Hb
Machine Learning Book: https://amzn.to/3RNmwfs
Libro de Aprendizaje automatico: https://amzn.to/3RVAFXU
Neural Networks for Babies: https://amzn.to/41SELoi

Video Equipment:
Background Color Light: https://amzn.to/3SgBDzG
Key Light: https://amzn.to/3NYwXLZ
Microphone: https://amzn.to/3H9UK89

Other:
Underrated Cheap Basketball: https://amzn.to/3RVzJTo
Amazing Basketball shorts: https://amzn.to/3vyRDUM
5 سال پیش در تاریخ 1398/05/03 منتشر شده است.
82,295 بـار بازدید شده
... بیشتر