Skip to main content
Documentation

How to find an equation from data

There are two ways to get an equation from a table of measurements. You can pick the form of the equation yourself, a straight line, a polynomial, an exponential, and let a tool work out its constants: that is curve fitting and ordinary regression. Or you can let a search look for the form as well as the constants, directly from the data: that is Symbolic Regression, and it is what an automated analysis on Diafunc does. This guide follows one real case from the table to the equation, with every figure taken from the public report.
The result is one readable model for the column you want to explain, with its quality measured on rows the search never saw, and a report that also says where the model is weak.

The data

The table is Yacht Hydrodynamics from the UCI Machine Learning Repository, published under CC BY 4.0: towing-tank measurements of sailing-yacht hulls at different speeds. It has 308 rows and 7 columns. Six columns describe the hull and the speed, and the seventh is what was measured.
ColumnRole
longitudinal_position_of_buoyancyInput
prismatic_coefficientInput
length_displacement_ratioInput
beam_draught_ratioInput
length_beam_ratioInput
froude_numberInput
residuary_resistanceTarget: the column to explain
Nobody told the analysis which of the six inputs matter, or what shape the relation has.

Why not a straight line

The obvious first try is a linear regression over all six inputs. The report runs it for you, as one of its baselines, and scores it on the same rows as the discovered model. On this table the straight line explains 65% of the variation of the resistance (R² 0.647). A third of what happens in the tank is left unexplained, which means the relation is not a line.
From here a curve fitter needs you to guess a better form. With six inputs there is no obvious guess.

Three choices before the launch

An automated analysis asks for three things, and none of them is the form of the equation.
1. The table. The file is uploaded as it is. The wizard shows how it will be read and a preview of the first rows.
2. The target, and your questions. Here the target is residuary_resistance. Three questions were typed in plain language, and the report answers each of them: what the resistance of a hull depends on most, how it grows with speed, and which hull-shape ratios matter and which hardly at all.
3. The depth. A depth is a time budget and a credit budget. This run used Standard: four hours and 10,000 credits. It finished after 2 hours and 42 minutes. The first chapters of a report, the ones about the data, are there within minutes; the search for the model takes the rest.
The full description of the wizard is in Analyses.

The equation that came back

This is the model the analysis discovered, as the report prints it:
Discovered model
residuary_resistance = 93.8 × tanh(-1.65 × prismatic_coefficient
    + 0.01 × longitudinal_position_of_buoyancy
    + 10.73 × froude_number
    − 0.027 × beam_draught_ratio
    − 4.25) + 94.3
Real output. 308 towing-tank measurements of yacht hulls, six inputs. The model was discovered, not written by hand.
It reads in one pass. The resistance is a saturating curve, a hyperbolic tangent, of a weighted sum of four inputs. The speed, froude_number, has by far the largest weight; the report puts its share of the model's reliance on inputs at 98.7%. The prismatic coefficient and the beam-draught ratio lower the resistance a little, the position of buoyancy raises it a little.
Two of the six inputs are not in the model at all: the length-displacement ratio and the length-beam ratio. The search was free to use them and found a model that does without. That is also an answer.

How good it is, measured on rows it never saw

Before the search started, 62 of the 308 rows were set aside. The search worked with the other 246. The figures to quote are the ones on the 62 held-out rows, because they say how the model does on data it has not seen.
MeasureOn the 62 held-out rows95% interval
Quality99.27%98.69% to 99.66%
Error0.57%0.27% to 1.03%
R²0.994260.98971 to 0.99733
Complexity20.7%
Against the baselines, on the same rows: the straight line reaches R² 0.647 and the discovered model 0.994, a lift of 0.347. The report calls that margin large and consistent row by row. Had the two been level, the report would have said that the relation is linear and that the extra structure adds nothing.
What each measure means, and how the rows are held out, is described in How Diafunc measures quality.

What the report says against its own model

A quality of 99% is not where the report stops. It raises one concern, marked Critical: the model is less accurate where the resistance is high. Across the held-out rows, split into thirds by predicted value, the spread of the misses in the top third is 12.9 times the spread in the bottom third.
Because of that concern the Deployment Readiness chapter gives the verdict Not ready: four checks pass, one warns, and one critical concern is open. The report recommends collecting more rows where the resistance is high, and validating the model on fresh rows before relying on it.
An equation alone would not have told you this. The equation is the readable part; the report is what lets you decide how far to trust it.
Real output. The Headline chapter of a report: what the model says, in plain English, and how it did on the rows it never saw.
The whole report is public: Yacht Hydrodynamics, the finished analysis.

When a curve fitter is enough

If your table has one input and you know the family of the curve, a curve fitter or a trendline in a spreadsheet answers the question in seconds, and an analysis that runs for an hour or more is the wrong tool. The search is for the other case: several inputs, or a form nobody can name in advance.

Your own table

Upload a CSV or Excel file, choose the column to explain, and launch. An analysis runs from about an hour, and you get an email when it is done. About a hundred rows per target is where the report stops warning that the table is small.

What next?