Question: file to google drive: https://drive.google.com/drive/folders/11fc_ahJ1Z2qSU2S78WaL1PKsc8QXbKSQ?usp=sharing Note: Multiple Linear Regression using Python. import pandas as pd import matplotlib.pyplot as plt import numpy as np from sklearn.preprocessing

file to google drive: https://drive.google.com/drive/folders/11fc_ahJ1Z2qSU2S78WaL1PKsc8QXbKSQ?usp=sharing

Note: Multiple Linear Regression using Python.

import pandas as pd

import matplotlib.pyplot as plt

import numpy as np

from sklearn.preprocessing import LabelEncoder, OneHotEncoder

from sklearn.compose import ColumnTransformer

from sklearn.model_selection import train_test_split

from sklearn.linear_model import LinearRegression

import statsmodels.api as sm

import statsmodels.formula.api as smf

data= pd.read_csv('Startups_company.csv')

data.head(10)

real_x = data.iloc[:,0:4].values

real_y = data.iloc[:,4].values

le = LabelEncoder()

real_x[:,3] = le.fit_transform(real_x[:,3])

oneHE = ColumnTransformer([("State", OneHotEncoder(), [3])], remainder = 'passthrough')

real_x = oneHE.fit_transform(real_x)

real_x = real_x[:,1:]

training_x,test_x, training_y,test_y = train_test_split(real_x,real_y,test_size=0.2,random_state=0)

MLR = LinearRegression()

MLR.fit(training_x,training_y)

pred_y = MLR.predict(test_x)

pred_y

test_y

MLR.coef_

MLR.intercept_

#y = b0 + b1x1 + b2x2----------+bnxn

real_x = np.append(arr=np.ones((50,1)).astype(int),values=real_x,axis=1)

#X = np.append(arr=np.ones((50,1),dtype=np.int), values = X,axis = 1)

x_opt = real_x[:,[0,1,2,3,4,5]]

reg_OLS = sm.OLS(real_y,x_opt)

reg_OLS.summary()

question: how to fix this problem reg_OLS = sm.OLS(real_y,x_opt) & reg_OLS.summary() this type problem:

TypeError: ufunc 'isfinite' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe'' 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!