Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

import numpy as np import scipy.linalg as linalg import matplotlib.pyplot as plt import least_square as LS #then call the function least_square_poly() as LS.least_square_poly() #---------------------------------------------------------- def

image text in transcribed

import numpy as np import scipy.linalg as linalg import matplotlib.pyplot as plt import least_square as LS #then call the function least_square_poly() as LS.least_square_poly()

#---------------------------------------------------------- def engin_efficiency(): # # input the data from the table, make them to be np.array so that they can be scaled # xData = yData =

# # call the least_square_poly() for regression #

# print the standard deviation

# plot your data points

# plot linear regression line

# plot quadratic regression curve

# set the labels and lengends etc

# # find the predicted values that are for years 2000 and 2016, set the title properly #

plt.savefig("engin_efficiency.png") plt.show()

Any help would be great please! Will thumbs up

Prob. 3 Table 1 shows historical data of the thermal efficiency of some early engines. Write a Python script to apply both linear regression and quadratic regression to predict the thermal efficiency in year 2000 and year 2016. Study the demo code least.square.py shown in class (also attached in the project gzip file and imported in p3 engin.eff.py). You should reuse the functions already coded in least.square.py Engine model Newcomen Smeaton Smeaton Watt Watt 1718 1767 1774 0.5 0.8 1792 1816 1828 1834 1878 1906 2.7 4.5 7.5 12.0 17.0 17.2 23.0 nd Cornish Woolf com Corliss comp Triple expansion Table 1: Historical data of thermal efficiency of some early engines. (You can neglect the 3rd column in the table.) Plot the data points (using any marker you prefer, but set markersze=10), and the two regression curves, in the same figure. Show your prediction numbers of the efficiency in the title of your plot, eg, if the numbers you get for linear and quadratic regression, respectively, are 30.1% and 35.0% for 2000, and 45.08% and 50.04%for 2016, then your title should be 2000eff .= (0.301, 0.350) , 2016eff.= (0.451, 0.500) . On your plot, keep 3 decimal digits in the title. When you finish. you should get a plot similar to Fig. 1, with all of the x- and y-labels, axis ticks and values, and the title, properly specified. 2000eff.=(0.350,0.454), 2016eff.=(0.372,0.497) 0.5 data points linear 0.4Hquadratioc 0.3 0.2 0.0L -0 1750 1800 1850 1900 1950 2000 2050 year Figure 1: Sample plot for the engine efficiency problem. (The numbers you put in the title need to be the ones from your own regressions. They may or may not be different from the ones shown in this figure.)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning Databases With PostgreSQL From Novice To Professional

Authors: Richard Stones, Neil Matthew

2nd Edition

1590594789, 978-1590594780

More Books

Students also viewed these Databases questions