Project

Curve Fitting

*********** Remarks of the Evaluator ************

  • You have not evaluated goodness of fit

Also, the way you have estimated error is inadequate for curve fitting, in curve fitting, the error is estimated in two ways

  • The sum of squares due to error (SSE)
  • Root mean squared error (RMSE)

Also, blindly increasing the degree of the polynomial will not result in a better fit in all cases. The best way to proceed then is to divide the datapoints in sub regions and curve fit for each region seperately.

SUGGESTION (GENERAL):

The other thing that you can do is to attach the code and images in

projects.skill-lync.com and paste the link over here.

If you have any doubts please ask us on WHATSAPP or raise a ticket on FRESHDESK or even call us to clarify all your doubts.

Please don\'t submit incomplete work as these challenges are made with an intuition of improving your understanding of the topic.

So, attempt all challenges sincerely.

Thank you.

*****************************************

1. What does popt and pcov mean?

popt: It gives an array with the optimal values for the parameters so that the sum of the squared residuals of data is minimized

pcov:It is a 2d array with the estimated covariance of the parameters in popt. It can be used to calculate the the standard deviation errors of popt.

2. What does np.array(temperature) do?

This function stores the values of temperature in the form of array and passes it to the function numpy.

3. What does the * in *popt mean?

It stores the values of the constant parameters in the array popt.
\"\"\"
Curve Fitting Program 
\"\"\" 
import numpy as np
import matplotlib.pyplot as plt 
from scipy.optimize import curve_fit


#Curve fit function
def func(t,a,b,c,d,e,f):
	return a*pow(t,5)+ b*pow(t,4)+ c*pow(t,3)+ d*pow(t,2)+ e*t+ f

#Reading thermodynamic data file

def read_file():
	temperature=[]
	cp=[]
	for line in open(\'data\',\'r\'):
		values=line.split(\',\')
		temperature.append(float(values[0]))
		cp.append(float(values[1]))

	return[temperature,cp]

#Main program
temperature,cp=read_file()
popt,pcov=curve_fit(func,temperature,cp)
fit_cp=func(np.array(temperature),*popt)

plt.plot(temperature,cp,color=\"blue\",linewidth=3)
plt.plot(temperature,fit_cp,color=\"red\",linewidth=3)
plt.legend([\'Actual data\',\'Curve fit\'])
plt.xlabel(\'temperature[K]\')
plt.ylabel(\'cp\')

plt.show()

1. Linear Function Curve.

2. Cubic Function Curve.

3. Fith Degree Function.

As the degree of the polynomial function increases , the more fit the curve becomes starting from the linear to cubic to degree five.

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.