Giter Site home page Giter Site logo

Comments (5)

lucasmaystre avatar lucasmaystre commented on September 23, 2024 1

Hi @darkdark87 I just released a new version with a fix (v0.1.5). Hopefully it works now—let me know if you still have issues.

from kickscore.

lucasmaystre avatar lucasmaystre commented on September 23, 2024

Hi @darkdark87 , thanks for the kind words!

I've actually never had to save models before. I just tried using pickle now at the end of this colab notebook:

import pickle

with open("test.pkl", "wb") as f:
    pickle.dump(model, f)

with open("test.pkl", "rb") as f:
    m2 = pickle.load(f)

m2.plot_scores(
        items=["LAL", "CHI", "BOS"],
        resolution=10/seconds_in_year,
        figsize=(14.0, 3.0),
        timestamps=True)

and it seems to work fine. Could you share a minimum working example where it fails?

from kickscore.

darkdark87 avatar darkdark87 commented on September 23, 2024

Hi @lucasmaystre

I believe the errors lies with the number of teams. If I increase the number of teams by a factor 3 I receive an error when pickling the model.

I created a minimum "working example" in this notebook.

from kickscore.

lucasmaystre avatar lucasmaystre commented on September 23, 2024

Thanks, the example was helpful. I think I understand where the problem—there are circular references between Item and Observation, and I understand it trips pickle up after a certain point.

Putting this on my TODO list, but it'll probably have to wait for a few weeks.

In the meantime, if all you're interested in doing with the reloaded model is to make predictions, the following should work reasonably well:

import pickle

# Saving.
fitters = {name: val.fitter for name, val in model.item.items()}
with open("test1.pkl", "wb") as f:
    pickle.dump(fitters, f)

# Re-loading.
with open("test1.pkl", "rb") as f:
    fitters = pickle.load(f)

m2 = ks.BinaryModel()
dummy = ks.kernel.Constant(var=1.0)

for name, fitter in fitters.items():
    m2.add_item(name, kernel=dummy)
    m2.item[name].fitter = fitter

It only saves the parameters of the model (which are in the items' fitter property) though, so you won't be able to retrain it, or inspect the observations it was trained on, etc. However, model.probabilites(), item.predict() should work fine.

I'll leave the issue open until I fix persistency in a cleaner way.

from kickscore.

darkdark87 avatar darkdark87 commented on September 23, 2024

Sounds good @lucasmaystre
My use case requires retraining of the persisted model, so I'll wait.

Thank you.

from kickscore.

Related Issues (11)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.