Machine Learning Tutorial Python – 2: Linear Regression Single Variable




[ad_1]

In this tutorial we will predict home prices using linear regression. We use training data that has home areas in square feet and corresponding prices and train a linear regression model using sklearn linear regression class. Later on predict method is used on linear regression object to make actual forecast.

#MachineLearning #PythonMachineLearning #MachineLearningTutorial #Python #PythonTutorial #PythonTraining #MachineLearningCource #LinearRegression

Topics that are covered in this Machine Learning Video:
0:00 Simple linear regression
1:59 Linear equation
2:43 Import sklearn library
2:22 Import data in dataframe
3:52 Plot scatter plot
5:26 Create Linear Regression object
13:35 Exercise at the end to predict canada’s per capita income

Topic Highlights:
1) What is linear regression
2) Mean squared error
3) Predict home prices by minimizing mean squared error (or MSE)
4) Exercise at the end to predict canada’s per capita income

Next Video:
Machine Learning Tutorial Python – 3: Linear Regression Multiple Variables: https://www.youtube.com/watch?v=J_LnPL3Qg70&list=PLeo1K3hjS3uvCeTYTeyfe0-rN5r8zn9rw&index=3

Very Simple Explanation Of Neural Network: https://www.youtube.com/watch?v=ER2It2mIagI

Code: https://github.com/codebasics/py/tree/master/ML/1_linear_reg
Correction: at 6:53, use reg.predict([[3300]]) instead of reg.predict(3300) as api specification has changed.
Exercise solution: https://github.com/codebasics/py/blob/master/ML/1_linear_reg/1_linear_regression.ipynb

Populor Playlist:
Data Science Full Course: https://www.youtube.com/playlist?list=PLeo1K3hjS3us_ELKYSj_Fth2tIEkdKXvV

Data Science Project: https://www.youtube.com/watch?v=rdfbcdP75KI&list=PLeo1K3hjS3uu7clOTtwsp94PcHbzqpAdg

Machine learning tutorials: https://www.youtube.com/watch?v=gmvvaobm7eQ&list=PLeo1K3hjS3uvCeTYTeyfe0-rN5r8zn9rw

Pandas: https://www.youtube.com/watch?v=CmorAWRsCAw&list=PLeo1K3hjS3uuASpe-1LjfG5f14Bnozjwy

matplotlib: https://www.youtube.com/watch?v=qqwf4Vuj8oM&list=PLeo1K3hjS3uu4Lr8_kro2AqaO6CFYgKOl

Python: https://www.youtube.com/watch?v=eykoKxsYtow&list=PLeo1K3hjS3uv5U-Lmlnucd7gqF-3ehIh0&index=1

Jupyter Notebook: https://www.youtube.com/watch?v=q_BzsPxwLOE&list=PLeo1K3hjS3uuZPwzACannnFSn9qHn8to8

To download csv and code for all tutorials: go to https://github.com/codebasics/py, click on a green button to clone or download the entire repository and then go to relevant folder to get access to that specific file.

Website: http://codebasicshub.com/
Facebook: https://www.facebook.com/codebasicshub
Twitter: https://twitter.com/codebasicshub

Source


[ad_2]

Comment List

  • codebasics
    November 23, 2020

    Step by step roadmap to learn data science in 6 months: https://www.youtube.com/watch?v=H4YcqULY1-Q

  • codebasics
    November 23, 2020

    Others were teaching what is linear regression, but everyone failed to teach how to implement with real example. I'm so happy that I found this channel!!!!!! Love from India <3

  • codebasics
    November 23, 2020

    getting errors in re.predict(3300) line. what to do?? error said to reshape the array

  • codebasics
    November 23, 2020

    Would it be possible to put the exercises and files in a shareable google drive?

    Thank you.

  • codebasics
    November 23, 2020

    Got the 2020 predicted value 41288.69409442

  • codebasics
    November 23, 2020

    answer: 41288.69409442

  • codebasics
    November 23, 2020

    hi. d.to_csv generate text file but i want csv what can I do?

  • codebasics
    November 23, 2020

    Excellent lec sir, but how do we come to know when to use list of list(2d array) and when not to use it

  • codebasics
    November 23, 2020

    Thanks for the amazing tutorial sir. I understood it completely and even done the exercise., from today evening I am gonna start follow your tutorials. lets hope that I go far in it

  • codebasics
    November 23, 2020

    hello sir,
    i like your teaching process and this is phenomenal
    can i get your email to contact ?

  • codebasics
    November 23, 2020

    Hello, I ran this code and everything was going fine but at last i am getting one error . And i am not able to find any error in my code . So can u show me some direction in it?

    The error is "ValueError: Expected 2D array, got scalar array instead:

    array=3300.

    Reshape your data either using array.reshape(-1, 1) if your data has a single feature or array.reshape(1, -1) if it contains a single sample."

    Thanks in advance πŸ™‚

  • codebasics
    November 23, 2020

    Finally this video made me clear and to convert from Octave to python. And, I did some experiments on data set by stanford university from where i learned ML and it worked. Thanks you so much. And, You are doing such an wonderful job making a lot of stuffs clear. I hope my comment will convey you

  • codebasics
    November 23, 2020

    Sir this is really easy for us to learn

  • codebasics
    November 23, 2020

    I am not able to open the link of excercise.

  • codebasics
    November 23, 2020

    Clear explanation πŸ™ thank you sir for your videos . Doing a great job to the society

  • codebasics
    November 23, 2020

    Thank you so much sir, i tried that canada prediction, its very useful and i got 41288.69409
    for 2020

  • codebasics
    November 23, 2020

    how to download the file having per capita income

  • codebasics
    November 23, 2020

    Im getting error that file not found while running the first step of displaying excel sheet

  • codebasics
    November 23, 2020

    Not able to show the price on y axis ? Whts the problem ???? showing 1,2,3,4,5,6,7 instead of price 550000, 565000,….

  • codebasics
    November 23, 2020

    Really simple way Good explain

  • codebasics
    November 23, 2020

    Nice video !

    This may be useful for beginners:
    Hello, i have made my own algorithm which gets similar results to linear regression it is for very beginner due to its easy syntax.
    https://youtu.be/-UdDMcTc6rM
    To get access to this module click the video link above and ask in comments . The module is in developement BETA

  • codebasics
    November 23, 2020

    This I think is the simplest, yet useful explanation of linear regression, coupled with a code demonstration. I’ve had a hard time checking various resources to understand what this algorithm means in simplest terms, and I never had the luck.

    Man, somehow you nailed it so well. Keep rocking!!

    Looking to explore more topics.

  • codebasics
    November 23, 2020

    Very simple to understand. Done well

  • codebasics
    November 23, 2020

    HI. I am struggling with download the exercise file from Github, is there any way to show us step by step? thank you.

  • codebasics
    November 23, 2020

    Sir meri csv file read wale step mein hi error show ho rha hai . Please suggest meri mistake kha hai πŸ™

  • codebasics
    November 23, 2020

    Best of Best πŸ‘πŸ‘πŸ‘

  • codebasics
    November 23, 2020

    I am getting error on reg.fit(df[['area']],df.price)..Can anyone help

  • codebasics
    November 23, 2020

    Thanks n thanks again sirπŸ‘πŸ‘πŸ™πŸ™

  • codebasics
    November 23, 2020

    This is showing error, please help with the correct format and in the video it executed successfully for the trainer
    reg = linear_model.LinearRegression

    reg.fit([['df.area']],df.price)

  • codebasics
    November 23, 2020

    In the canada per capita income dataset, how to access the per capita… attribute ? It contains spaces that is the problem ..

  • codebasics
    November 23, 2020

    41288.69409442 is the answer for exercise problem.

  • codebasics
    November 23, 2020

    The per capita income in US$ for the year 2020 is: [41288.69409442]. Is it okay?

  • codebasics
    November 23, 2020

    You just making my life easier.

  • codebasics
    November 23, 2020

    nice session

  • codebasics
    November 23, 2020

    instead of uploading my dataset .How can I acces from My folder.
    also the new dataset after predict also save in my folder

  • codebasics
    November 23, 2020

    Excellent teaching sir

  • codebasics
    November 23, 2020

    after compile line 6 i got this error. please guide
    ValueError: Expected 2D array, got scalar array instead:

    array=3300.

    Reshape your data either using array.reshape(-1, 1) if your data has a single feature or array.reshape(1, -1) if it contains a single sample.

  • codebasics
    November 23, 2020

    Loved the simple explanation. Thank You.

  • codebasics
    November 23, 2020

    I did the assignment for the Canada_per_capita, I predicted next 30 years and added it to csv … πŸ™‚
    https://github.com/JaskaranKaurGill/LinearRegression/tree/master/Canada_per_capita_assignment

  • codebasics
    November 23, 2020

    Hello Sir! I was really amazed with such an instilling video sets from sratch . But I got an error- Dataframe Object has no attribute area , while plotting the scatter plot.Can you please help me?

  • codebasics
    November 23, 2020

    amazing work sir Thanks alot

  • codebasics
    November 23, 2020

    Thanks bro..by the way what is your good name?

  • codebasics
    November 23, 2020

    reg = linear_model.LinearRegression()

    reg.fit(df[['area']],df.price)
    after this code i m not able to predict the value of array using this reg.predict(3300)
    kindly help

  • codebasics
    November 23, 2020

    reg.predict(3300) error 2d array expected

Write a comment