Guide to Data Handling¶
InferPy leverages existing Pandas functionality for reading data. As a consequence, InferPy can
learn from datasets in any file format handled by Pandas. This is possible because the method
inferpy.ProbModel.fit(data)
accepts as input argument a Pandas DataFrame.
In the following code fragment, an example of learning a model from a CVS file is shown:
import inferpy as inf
import pandas as pd
data = pd.read_csv("inferpy/datasets/test.csv")
N = len(data)
with inf.ProbModel() as m:
thetaX = inf.models.Normal(loc=0., scale=1.)
thetaY = inf.models.Normal(loc=0., scale=1.)
with inf.replicate(size=N):
x = inf.models.Normal(loc=thetaX, scale=1., observed=True, name="x")
y = inf.models.Normal(loc=thetaY, scale=1., observed=True, name="y")
m.compile()
m.fit(data)
m.posterior([thetaX, thetaY])