INTERPOLATION
InterpolatedUnivariateSpline
1-D interpolating spline for a given set of data points.
Example of usage
Python API reference included; executable data demonstration pending review.
Usage / limitations
+Use when: Estimate values between samples.
−Limitations: Check input requirements, mathematical assumptions and version-specific behaviour before using.
Mathematical formula
See method documentation: implementation and assumptions vary.
Sample dataShow
{
"variable": "observations",
"domain": "Environmental monitoring — hourly weather station measurements",
"feature_names": [
"hour",
"temperature_c"
],
"records": [
{
"hour": 0,
"temperature_c": 14.0
},
{
"hour": 1,
"temperature_c": 15.2
},
{
"hour": 2,
"temperature_c": 17.1
},
{
"hour": 3,
"temperature_c": 18.0
},
{
"hour": 4,
"temperature_c": 19.4
},
{
"hour": 5,
"temperature_c": 20.1
},
{
"hour": 6,
"temperature_c": 21.6
},
{
"hour": 7,
"temperature_c": 22.0
}
]
}
Code example (Python)
observations = {'feature_names': ['hour', 'temperature_c'], 'records': [{'hour': 0, 'temperature_c': 14.0}, {'hour': 1, 'temperature_c': 15.2}, {'hour': 2, 'temperature_c': 17.1}, {'hour': 3, 'temperature_c': 18.0}, {'hour': 4, 'temperature_c': 19.4}, {'hour': 5, 'temperature_c': 20.1}, {'hour': 6, 'temperature_c': 21.6}, {'hour': 7, 'temperature_c': 22.0}]}
# DataLens.ai example — InterpolatedUnivariateSpline
# Domain: environmental temperature monitoring.
# Input observations is supplied by the Sample Data section.
import numpy as np
from scipy.interpolate import InterpolatedUnivariateSpline
# Read recorded measurements with explicit, meaningful feature names.
x = np.array([row["hour"] for row in observations["records"]], dtype=float)
y = np.array([row["temperature_c"] for row in observations["records"]], dtype=float)
# Perform the specified interpolation and validate expected properties.
curve = InterpolatedUnivariateSpline(x, y, k=3)
result = curve(x)
assert np.allclose(result, y, atol=1e-8)
# Self-test completed without raising an assertion error.
print("Expected output verified")
# DataLens.ai example — InterpolatedUnivariateSpline
# Domain: environmental temperature monitoring.
# Input observations is supplied by the Sample Data section.
import numpy as np
from scipy.interpolate import InterpolatedUnivariateSpline
# Read recorded measurements with explicit, meaningful feature names.
x = np.array([row["hour"] for row in observations["records"]], dtype=float)
y = np.array([row["temperature_c"] for row in observations["records"]], dtype=float)
# Perform the specified interpolation and validate expected properties.
curve = InterpolatedUnivariateSpline(x, y, k=3)
result = curve(x)
assert np.allclose(result, y, atol=1e-8)
# Self-test completed without raising an assertion error.
print("Expected output verified")