Implementing Multiple Linear Regression in Python

Поділитися
Вставка
  • Опубліковано 4 лип 2020
  • In this lecture, we talk about how to implement Linear Regression in Python.
    We provide a plethora of courses ranging from Python to Essential Maths to Machine Learning and Deep Learning with industry relevant Capstone Projects. We also strive to help our students get high paying jobs in the field of Data Science through Resume Preparation, Mock Interviews and our connections with various HR Partners.
    For more information, materials and Jupyter notebooks, please visit our website floatint.thinkific.com

КОМЕНТАРІ • 19

  • @saitarun6562
    @saitarun6562 2 роки тому

    thank you so much very clear explanation very helpful.

  • @mohitnamdev408
    @mohitnamdev408 2 роки тому

    thank you so much sir.
    It is very clear explanation and helpful.

  • @monee1907
    @monee1907 3 роки тому

    Awesome Video ...very helpful.

  • @snivesz32
    @snivesz32 3 роки тому

    Thank you. What is the purpose of scaling the exogenous variables before regression? It’s my understanding that that will only change the scale of the betas but not the significance of them.

  • @sam-mv6vj
    @sam-mv6vj 2 роки тому

    Thanks that's really helpful

  • @christheprophet6583
    @christheprophet6583 2 роки тому

    Good explanation. I don't know if you did not check for outliers on purpose.

  • @improgrammer4473
    @improgrammer4473 2 роки тому +8

    Here is the full working code of this video, Use jupyter notebook for understanding.
    import numpy as np
    import matplotlib.pyplot as plt
    import pandas as pd
    from sklearn.model_selection import train_test_split
    from sklearn.linear_model import LinearRegression
    from sklearn.metrics import mean_squared_error, r2_score
    import math
    dataset = pd.read_csv("50_Startups.csv")
    print(dataset.shape)
    dataset.head()
    plt.scatter(dataset['Marketing Spend'] , dataset['Profit'])
    plt.title('Multiple Regression')
    plt.xlabel('Marketing Spend')
    plt.ylabel('Profit')
    plt.show()
    plt.scatter(dataset['Administration'] , dataset['Profit'])
    plt.title('Multiple Regression')
    plt.xlabel('Administration')
    plt.ylabel('Profit')
    plt.show()
    plt.scatter(dataset['R&D Spend'] , dataset['Profit'])
    plt.title('Multiple Regression')
    plt.xlabel('R & D Spend')
    plt.ylabel('Profit')
    plt.show()
    dataset['newyork']=np.where(dataset['State'] == 'New York' , 1, 0)
    dataset['florida']=np.where(dataset['State'] == 'Florida' , 1, 0)
    dataset['California']=np.where(dataset['State'] == 'California' , 1, 0)
    dataset['profit'] = dataset['Profit']
    dataset.drop(columns=['State'], axis=1,inplace=True)
    dataset.drop(columns=['Profit'], axis=1,inplace=True)
    print(dataset.head())
    X=dataset.iloc[:,:6]
    y=dataset.iloc[:,6:]
    X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=0, test_size = 0.25)
    from sklearn.preprocessing import MinMaxScaler
    scaler = MinMaxScaler()
    X_train =scaler.fit_transform(X_train)
    X_test = scaler.fit_transform(X_test)
    X_train[0:5]
    model = LinearRegression()
    model.fit(X_train , y_train)
    ypred = model.predict(X_test)
    print(ypred)
    math.sqrt(mean_squared_error(y_test, ypred))
    r2_score(y_test, ypred)

    • @sasikumaran4360
      @sasikumaran4360 11 місяців тому

      i need to perform stepwise regression will you help me

  • @alexmcaruthur6966
    @alexmcaruthur6966 Рік тому

    Thank you 🙏

  • @analie1372
    @analie1372 3 роки тому

    can i plot regression line on this?

  • @pooja3rdyrccertificatecade433
    @pooja3rdyrccertificatecade433 2 роки тому

    Sir I am getting key error in creating the figure object can u please help me with this

  • @cricplay5376
    @cricplay5376 Рік тому

    Could u please make a video on other ai models like rbf, anfis Or rnn?

  • @PsychMind0186
    @PsychMind0186 Рік тому

    where i can download the dataset???

  • @meetkcs
    @meetkcs Рік тому

    Excellent very simple way explained.
    Thank you for the KT.
    Can u plz share the dataset and code...I ll practice at my end once.

  • @mahashreer7887
    @mahashreer7887 3 роки тому

    Some error come how solve

  • @SaiSindhu06
    @SaiSindhu06 2 роки тому

    App or website name please

  • @rafaqathussain7259
    @rafaqathussain7259 Рік тому

    can u plz send whatsapp