Question: 2) Create a user defined function for the given Python program. Importing data into Python from filename.csv Use the same parameters and variables as defined
2) Create a user defined function for the given Python program. Importing data into Python from filename.csv Use the same parameters and variables as defined in the following Python programs. Run your programs 2- Least squares method 1- Least Squares Method xbar = sum(tv_ad)/ len(tv_ad) ybar - sum(sales)/ len(sales) bihat_numerator = 0 bihat_denominator = 0 num_of_samples - range(len(sales)) for i in num_of_samples: # x (tv_ad) and y (sales) have the same length blhat_numerator += (tv_ad[0) - xbar) (sales[U] - ybar) bihat_denominator + (tv_ad) - xbar)**2 bihat= blhat_numerator/ bihat_denominator bohat=ybar - bihat * xbar print(" Least Squares Method: sales = ", round(bohat,3), "+", round(b1hat,3)," tv_ad") 2) Create a user defined function for the given Python program. Importing data into Python from filename.csv Use the same parameters and variables as defined in the following Python programs. Run your programs 2- Least squares method 1- Least Squares Method xbar = sum(tv_ad)/ len(tv_ad) ybar - sum(sales)/ len(sales) bihat_numerator = 0 bihat_denominator = 0 num_of_samples - range(len(sales)) for i in num_of_samples: # x (tv_ad) and y (sales) have the same length blhat_numerator += (tv_ad[0) - xbar) (sales[U] - ybar) bihat_denominator + (tv_ad) - xbar)**2 bihat= blhat_numerator/ bihat_denominator bohat=ybar - bihat * xbar print(" Least Squares Method: sales = ", round(bohat,3), "+", round(b1hat,3)," tv_ad")
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
