jpn-- / larch

Larch: a Python tool for choice modeling
http://larch.newman.me
GNU General Public License v3.0
41 stars 14 forks source link

Scoring new data #5

Open supreetr opened 6 years ago

supreetr commented 6 years ago

I am trying to use a previously estimated model to score new data. Is there an equivalent of sklearn's predict function in Larch? Any help is much appreciated.

nortelli commented 5 years ago

Hello, I faced the same issue some time ago. As I could not find any built-in function that would do that, I figured out the following with the existing functions: – estimate model m on the train data; – run m.unprovision() to be able to change the data linked to m; – change the data linked to m using _change_data_fountain(df), where df is your new data; – run m.setUp(). After that, you should be able to get what you want by running m.loglike() or m.probability()! It looks kind of unnecessarily complex, but it does work in my case. Hope this helps!

jpn-- commented 5 years ago

As you might notice from the source code here, I am also in the process of bringing Larch version 5 online, which provides explicit compatibility directly with fit and predict interface of sklearn. An example will be posted soon(-ish).