Giter Site home page Giter Site logo

Comments (7)

mmalohlava avatar mmalohlava commented on May 21, 2024

Hi Mikhail,

right now we can serialize and deserialize models directly via H2O - look at https://github.com/h2oai/h2o-3/blob/master/h2o-core/src/main/java/water/api/ModelsHandler.java#L181-L208

The code export/import model to/from a given location. You can use similar code from Sparkling Water.

Later i will provide nicer Scala API.

Please, let me know if it works for you.

from sparkling-water.

shahrozhaider26 avatar shahrozhaider26 commented on May 21, 2024

Can you please provide scala code for this?

from sparkling-water.

mmalohlava avatar mmalohlava commented on May 21, 2024

At least Java code for import:

List<Key> importedKeys = new ObjectTreeBinarySerializer().load(FileUtils.getURI(mimport.dir));
Model model = (Model) importedKeys.get(0).get();

Java code for export

Model model = getFromDKV("model_id", mexport.model_id.key());
List<Key> keysToExport = new LinkedList<>();
keysToExport.add(model._key);
keysToExport.addAll(model.getPublishedKeys());

new ObjectTreeBinarySerializer().save(keysToExport, FileUtils.getURI(mexport.dir));

from sparkling-water.

Tian-Su avatar Tian-Su commented on May 21, 2024

Hi @mmalohlava,
I tried the Scala code here:

def exportH2OModel(model : Model[_,_,_], destination: URI): URI = {
val modelKey = model._key.asInstanceOf[Key[_ <: Keyed[_ <: Keyed[_ <: AnyRef]]]]
val keysToExport = model.getPublishedKeys()
// Prepend model key
keysToExport.add(0, modelKey)
new ObjectTreeBinarySerializer().save(keysToExport, destination)
destination
}
def loadH2OModel[M <: Model[_, _, _]](source: URI) : M = {
val l = new ObjectTreeBinarySerializer().load(source)
l.get(0).get().asInstanceOf[M]
}

It seems both exportH2OModel and loadH2OModel work well! Thank you very much!

from sparkling-water.

jakubhava avatar jakubhava commented on May 21, 2024

Hi, as @Tian-Su said, the ModelSerializationSupport trait contains methods exportH2OModel and loadH2OModel. These methods are preferred way how to export/load models.

If you need any more help, please feel free to reopen this issue or start new one.

Kuba

from sparkling-water.

BenRR avatar BenRR commented on May 21, 2024

Does ModelSerializationSupport support hdfs?

from sparkling-water.

mmalohlava avatar mmalohlava commented on May 21, 2024

@BenRR yes

from sparkling-water.

Related Issues (20)

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.