Class BaseScikitLearnContentLoader<ObjectType>

  • Type Parameters:
    ObjectType - The type of the scikit-learn object that the loader supports.
    All Implemented Interfaces:
    IScikitLearnContentLoader
    Direct Known Subclasses:
    GaussianNaiveBayesContentLoader

    public abstract class BaseScikitLearnContentLoader<ObjectType>
    extends Object
    implements IScikitLearnContentLoader
    A base class that implements common functionality shred among the scikit-learn object loaders. Each loader will provide a list of supported fields to BaseScikitLearnContentLoader instead of implementing the deserialization manually to simplify the loaders as much as possible.
    • Constructor Detail

      • BaseScikitLearnContentLoader

        protected BaseScikitLearnContentLoader​(String typeName)
        Instantiate a BaseScikitLearnContentLoader object.
        Parameters:
        typeName - The type name of the loader.
    • Method Detail

      • createResultObject

        protected abstract ObjectType createResultObject()
        An abstract method to initialize a new instance of the scikit-learn object supported by the loader.
        Returns:
        The unloaded scikit-learn object supported by the loader.
      • registerSetters

        protected abstract void registerSetters()
        An abstract method implemented by the derived classes that loads the layout of the binary format. BaseScikitLearnContentLoader uses this layout to load the object.
      • getTypeName

        public String getTypeName()
        Name of the loader. The name is stored in the header of the binary package file to be used during deserialization.
        Specified by:
        getTypeName in interface IScikitLearnContentLoader
        Returns:
        The name/id of the loader type.
      • loadContent

        public Object loadContent​(BinaryModelPackage buffer)
        Loads the scikit-learn object with the provided layout in registerSetters.
        Specified by:
        loadContent in interface IScikitLearnContentLoader
        Parameters:
        buffer - The buffer to load the object from.
        Returns:
        The fully initialized scikit-learn object.
      • registerDoubleField

        protected void registerDoubleField​(String name,
                                           IScikitLearnLoaderDoubleFieldSetter<ObjectType> setter)
        Registers a double field for the scikit-learn serialized layout.
        Parameters:
        name - Name of the field.
        setter - The setter callback to load the value of the scikit-learn object.
      • registerLongField

        protected void registerLongField​(String name,
                                         IScikitLearnLoaderLongFieldSetter<ObjectType> setter)
        Registers a long integer field for the scikit-learn serialized layout.
        Parameters:
        name - Name of the field.
        setter - The setter callback to load the value of the scikit-learn object.
      • registerNumpyArrayField

        protected void registerNumpyArrayField​(String name,
                                               IScikitLearnLoaderNumpyArrayFieldSetter<ObjectType> setter)
        Registers a numpy array field for the scikit-learn serialized layout.
        Parameters:
        name - Name of the field.
        setter - The setter callback to load the value of the scikit-learn object.
      • registerStringArrayField

        protected void registerStringArrayField​(String name,
                                                IScikitLearnLoaderStringArrayFieldSetter<ObjectType> setter)
        Registers a String array field for the scikit-learn serialized layout.
        Parameters:
        name - Name of the field.
        setter - The setter callback to load the value of the scikit-learn object.