technilesh.com

Machine Learning Model 2 : Project for Business model idea -Technilesh.com

 Machine Learning Model 2

    Machine Learning Model 2



    Basically the Multiple Linear regression is same as the linear equation only difference is the having many independent variable and in linear regression only on independent variable is there.

    Y = @ + # X       ( Linear regression )

     Y is dependent Variable 

    X is independent variable 

                @ is slope 

                # is linear regression constant

        

        Y = @ + #1 .X1 + #2 .X2 + #3X3 + #4 .X4

             Y is dependent Variable 

            X1,X2 ,X3 ,X4 is independent variable 

             @ is slope 

                #1 , #2 , #3 , #4 is MULTIPLE linear regression constant

    In multiple regression we compare many items that independent variable to dependent variable and predict the result 


    We Process the data firstly and then we work on the regression 

     data preprocessing 

    # template is heavnly need and also feature scaling is not need for mant time but if required we used

    import numpy as np
    import matplotlib.pyplot as plot
    import pandas as pd


    #import the data sets
    dataset = pd.read_csv('data.csv')
    X = dataset.iloc[: , :-1].values
    Y = dataset.iloc[: ,:3].values

    #split the set to traning and test sets

    from sklearn.model_selection import train_test_split
    X_train,X_test,Y_train,Y_test = train_test_split(X,Y,test_size=0.2# test size should be displayed

    #scaling
    from sklearn.preprocessing import StandardScaler
    sc_X = StandardScaler()
    X_train = sc_X.fit_transform(X_train)
    X_test  = sc_X.transform(X_test)

    # scale dumay vriable

    now we do an Multiple linear Rgression 


         


    # the multiple linear regression is having many component independent ,  Y = a+ax1+ax2....
    # we need to remove the coloum which is noy useful $ garbage in and out 
    # in = out ... ifthe variable which not impact on 

    # 5 method of building models 2,3 ,4 are step wise regression ...
    #1 all in : -  if you know that important varaible or just gave you and make model 
    # 2  : - 
    # 3
    # 4
    # 5
    import numpy as np
    import matplotlib.pyplot as plot
    import pandas as pd

    dataset = pd.read_csv('data.csv')
    # all expect the last is independ variable
    # 4 is dependent variable which is the last coloum and 
    X = dataset.iloc[:, :-1].values 
    Y = dataset.iloc[:, :4].values
    # categorial data
    from sklearn.preprocessing import LabelEncoder ,OneHotEncoder
    X = X.reshape(1,-3)
    labelencoder_X = LabelEncoder()   # index gaves which has coloum which has diff data type than int...
    X[:, 0]=labelencoder_X.fit_transform(X[:,0])

    onehotencoder = OneHotEncoder(OneHotEncoder(categories='auto'sparse=False))
       #dummy create  pasiing index 
    X = onehotencoder.fit_transform(X[0]).toarray()

    #split the set to traning and test sets



    #dumay variable the type , this used to remove the trap
    #removing tthe first index
    X = X [: ,:-1]


    from sklearn.model_selection import train_test_split
    X_train,X_test,Y_train,Y_test = train_test_split(X,Y,test_size=0.2# test size should be displayed

    # Mutiple Rehression 
    from sklearn.linear_model import LinearRegression
    regressor = LinearRegression()
    regressor.fit(X_train,Y_train)

    # now we learn all the model the traing set now we have to test the model using some variables

    Y_pred = regressor.predict(X_test)
    print(Y_pred)


    Amazon Offering Full time for SDE and Creative Asset Library: Apply Now Google Swags 2022 | Google Winter Swags : Apply Now