chainladder.read_pickle

Contents

chainladder.read_pickle#

chainladder.read_pickle(path)[source]#

Load an object serialized with to_pickle (dill format).

Parameters:
pathstr or path-like

Path to the pickle file.

Returns:
object

The deserialized triangle or estimator.

Examples

Pickling preserves all fitted parameters, including non-default settings. A Development configured with average='simple' and n_periods=4 produces identical factors before and after a round-trip through disk, and the restored estimator can still transform new data.

import chainladder as cl

tri = cl.load_sample("raa")
dev = cl.Development(average="simple", n_periods=4).fit(tri)
fd, p = tempfile.mkstemp(suffix=".pkl")
os.close(fd)
dev.to_pickle(p)
restored = cl.read_pickle(p)
os.remove(p)
print(dev.ldf_.values[0, 0, 0, :].round(4))
print(restored.ldf_.values[0, 0, 0, :].round(4))
print(restored.transform(tri).ldf_.values[0, 0, 0, :].round(4))
[4.5853 2.0204 1.2448 1.1646 1.1099 1.0433 1.0344 1.018  1.0092]
[4.5853 2.0204 1.2448 1.1646 1.1099 1.0433 1.0344 1.018  1.0092]
[4.5853 2.0204 1.2448 1.1646 1.1099 1.0433 1.0344 1.018  1.0092]