liveBook · Manning

Curve fitting

As explained in Optimization Algorithms: AI techniques for design, planning, and control problems

The process of selecting function parameters so a curve represents observed data or target relationships.

Curve fitting selects function parameters so a curve approximates observed data. A real-valued genetic algorithm can search for polynomial coefficients while minimizing mean squared error (MSE). section 8.2.2

Third-order polynomial

Fit y = ax³ + bx² + cx + d to five data points. Each candidate is a coefficient vector [a, b, c, d]; substituting it into the polynomial produces predictions whose MSE measures fitness. For [1, 2, 3, 4], the worked MSE is 122.83; for [2, 2, 2, 2], it is 3,662.32. section 8.2.2

The genetic search proceeds by:

  • Representing each candidate curve with real-valued coefficients. section 8.2.2
  • Evaluating predictions and minimizing their MSE. section 8.2.2
  • Creating offspring through whole arithmetic crossover and mutation, balancing exploration with exploitation. section 8.2.2
Table 8.2 Curve-fitting problem data (view table figure)

x

0

1.25

2.5

3.75

5

y

1

5.22

23.5

79.28

196

Browse the x and y values used by the curve-fitting example. section 8.2.2

How Optimization Algorithms: AI techniques for design, planning, and control problems covers it

How deep it goes
Descends from polynomial definition through hand-worked MSE, crossover, mutation, and a Python implementation.
Examples
Uses five data points, two coefficient vectors, MSE tables, and real-valued genetic-algorithm code.
What it assumes
Assumes polynomial coefficients, candidate solutions, genetic operators, and MSE can be interpreted.
What you can do after
Apply it via NumPy and pymoo to search for best-fit third-order polynomial coefficients.
How it connects
Connects polynomial regression, genetic algorithms, crossover, mutation, and mean squared error.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Optimization Algorithms: AI techniques for design, planning, and control problems. The section links point to the parts of the book it draws on.