Download the PHP package ourenergy/imputer without Composer
On this page you can find all versions of the php package ourenergy/imputer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ourenergy/imputer
More information about ourenergy/imputer
Files in ourenergy/imputer
Package imputer
Short Description A library for filling in missing data
License MIT
Informations about the package imputer
Imputer
A library for filling in missing data by applying strategies. Inspired by php-ai/php-ml.
Installation
Usage
Imputer works by taking a list of array keys, and a partial set of values, then filling in the gaps. A gap is any key which exists in the key list, which doesn't have a corresponding value.
Say we had a set of incomplete data;
We can apply a linear interpolation to guess at what the values in between might be;
The result will be a completed set of data;
Strategies
Out of the box Imputer provides a few basic strategies. You can write your own by implementing the Imputer\Strategy
interface.
Linear Interpolation
As described above, the LinearInterpolation
strategy will generate a number of steps between the previous and next
known values.
e.g. 3 steps between 1.0 and 3.0 will create [1.5, 2.0, 2.5]
Weighted Interpolation
Similar to the LinearInterpolation
strategy, it will interpolate missing values, but with the added capability of
applying a weight to each result. This can be useful for applying historical trends to computed data or when you don't
want a straight line between points on your graph.
Will result in the following;
Substitution
The Substitution
strategy will take an existing set of values and use them to fill in any gaps.
Will result in the following;