All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
ABSTRACT: Curve fitting means to find a mathematical expression which represents a line or curve that fit the data the best. The best means with the minimum error or we can say it represents the best approximation for the data. Interpolation and least square methods are two of the most widely used techniques One of the…
Jerrold C William
updated on 06 Jun 2019
ABSTRACT:
Curve fitting means to find a mathematical expression which represents a line or curve that fit the data the best. The best means with the minimum error or we can say it represents the best approximation for the data. Interpolation and least square methods are two of the most widely used techniques
One of the most interesting problems in supervised machine learning is to find the best fit for the existing data which called regression. Suppose you have three points. Using a polynomial with degree two you can fit the curve to your point. Generally it is not a proper way. It may cause over-fitting. It means that the generalization is not considered here. In other words the error of the chosen model will be high when the model is applied for a new data. Therefore, validation techniques such as cross validation are used to solve this problem. In cross validation, the data is split into k folds (e.g. 10 folds). Then, the first fold is used to validate the model. After that, the next fold is used for validation and so on. Finally the mean of errors is calculated. The model with lower mean error is chosen.
The best curve fit is an interpolation. The error will be zero. There are an infinite number of such exact interpolatory models. So the phrase "the best curve fit" is meaningless.
THE CODE:
clear all
close all
clc
% loading the data set
cp_data = load('data');
temperature = cp_data(:,1);
specific_heat = cp_data(:,2);
% Curve fit
% specific_heat = a*T + b linear polynomial
co_effs1 = polyfit(temperature,specific_heat,1);
predicted_cp_data1 = polyval(co_effs1,temperature);
% specific_heat = a*T^2 + b*T + c cubic polynomial
co_effs2 = polyfit(temperature,specific_heat,3);
predicted_cp_data2 = polyval(co_effs2,temperature);
% specific_heat for 5th degree polynomial
co_effs3 = polyfit(temperature,specific_heat,5);
predicted_cp_data3 = polyval(co_effs3,temperature);
% Curve fit comparison
figure(1)
plot(temperature,specific_heat,'linewidth',5)
hold on
plot(temperature,predicted_cp_data1,'linewidth',3,'color','r')
xlabel('Temperature [K]')
ylabel('Specific Heat [KJ/Kmol-K]')
legend('Original Dataset', 'Curve Fit')
figure(2)
plot(temperature,specific_heat,'linewidth',5)
hold on
plot(temperature,predicted_cp_data2,'linewidth',3,'color','r')
xlabel('Temperature [K]')
ylabel('Specific Heat [KJ/Kmol-K]')
legend('Original Dataset', 'Curve Fit')
figure(3)
plot(temperature,specific_heat,'linewidth',5)
hold on
plot(temperature,predicted_cp_data3,'linewidth',3,'color','r')
xlabel('Temperature [K]')
ylabel('Specific Heat [KJ/Kmol-K]')
legend('Original Dataset', 'Curve Fit')
hold off
OBSERVATIONS:
THE GRAPH:
I have not evaluated the goodness of fit (by coding not using the inbuilt function)
Also, I have not estimated errors, in curve fitting, the error is estimated in two ways (by coding not using the inbuilt function).
Those are
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 data points in subregions and curve fit for each region separately.
Also, exploring on the fit( ) command and curve fitting toolbox in matlab is interesting, this provides us with a plethora of options in optimizing a fit without using multiple equations and also calculates the fit characteristics.
Leave a comment
Thanks for choosing to leave a comment. Please keep in mind that all the comments are moderated as per our comment policy, and your email will not be published for privacy reasons. Please leave a personal & meaningful conversation.
Other comments...
SHELL MESHING OF AN INTERIOR PANEL SUBSTRATE FOR FINITE ELEMENT ANALYSIS
SHELL MESHING OF A INTERIOR PANEL SUBSTRATE FOR FINITE ELEMENT ANALYSIS OBJECTIVE: Structural mesh is oftained for the complex interior panel plastics of a car for finite element analysis, by extracting mid surfaces with thickness elements using manual and auto generated methods. ABSTRACT & PRE-REQUISITES:…
26 Jul 2019 05:13 AM IST
MESHING A BONNET FOR STRUCTURAL ANALYSIS USING ANSA
MESHING A BONNET FOR STRUCTURAL ANALYSIS USING ANSA OBJECTIVE: The given CAD of a car bonnet is to be meshed for structural analysis with the required mesh parameters. ABSTRACT: To work with thin-walled solids, using a midsurface shell model can reduce the degrees of freedom in your model by factors of ten…
16 Jul 2019 06:51 AM IST
SURFACE WRAP OF AN ENGINE ASSEMBLY
SURFACE WRAP OF AN ENGINE ASSEMBLY OBJECTIVE: To extract a surface wrap of a CAD model, thereby eliminating the control volumes from which the 3D structure of meshed elements have been obtained. PROJECT WALKTHROUGH: Firstly, the topology of the CAD has to be taken care of, in order to eliminate any possibility of…
28 Jun 2019 08:28 AM IST
SURFACE MESHING OF A BMW M6
OBJECTIVE: The given CAD model of BMW M6 is to be eliminated from it\'s topological errors & render surface mesh, expel the errors occuring during the wholesome process. PREREQUISITES: CAD CLEAN UP & ITS USES: Meshing for FEA and CFD is simple: Just start with your CAD model, break it up into a bunch of small pieces,…
06 Jun 2019 11:58 AM IST
Related Courses
0 Hours of Content
Skill-Lync offers industry relevant advanced engineering courses for engineering students by partnering with industry experts.
© 2025 Skill-Lync Inc. All Rights Reserved.