Class BaseScikitLearnContentLoader<ObjectType>
- java.lang.Object
-
- ai.sklearn4j.core.packaging.loaders.BaseScikitLearnContentLoader<ObjectType>
-
- Type Parameters:
ObjectType- The type of the scikit-learn object that the loader supports.
- All Implemented Interfaces:
IScikitLearnContentLoader
- Direct Known Subclasses:
BernoulliNaiveBayesContentLoader,BinarizerContentLoader,CategoricalNaiveBayesContentLoader,ComplementNaiveBayesContentLoader,GaussianNaiveBayesContentLoader,LabelBinarizerContentLoader,LabelEncoderContentLoader,MaximumAbsoluteScalerContentLoader,MinimumMaximumScalerContentLoader,MultiLabelBinarizerContentLoader,MultinomialNaiveBayesContentLoader,NormalizerContentLoader,RobustScalerContentLoader,StandardScalerContentLoader
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 Summary
Constructors Modifier Constructor Description protectedBaseScikitLearnContentLoader(String typeName)Instantiate a BaseScikitLearnContentLoader object.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract ObjectTypecreateResultObject()An abstract method to initialize a new instance of the scikit-learn object supported by the loader.StringgetTypeName()Name of the loader.ObjectloadContent(BinaryModelPackage buffer)Loads the scikit-learn object with the provided layout in registerSetters.protected voidregisterDictionaryField(String name, IScikitLearnLoaderDictionaryFieldSetter<ObjectType> setter)Registers a dictionary field for the scikit-learn serialized layout.protected voidregisterDoubleField(String name, IScikitLearnLoaderDoubleFieldSetter<ObjectType> setter)Registers a double field for the scikit-learn serialized layout.protected voidregisterListField(String name, IScikitLearnLoaderListFieldSetter<ObjectType> setter)Registers a list field for the scikit-learn serialized layout.protected <ArrayType>
voidregisterListOfNumpyArrayField(String name, IScikitLearnLoaderListOfNumpyArrayFieldSetter<ObjectType,ArrayType> setter)Registers a list of numpy array field for the scikit-learn serialized layout.protected voidregisterLongField(String name, IScikitLearnLoaderLongFieldSetter<ObjectType> setter)Registers a long integer field for the scikit-learn serialized layout.protected voidregisterNumpyArrayField(String name, IScikitLearnLoaderNumpyArrayFieldSetter<ObjectType> setter)Registers a numpy array field for the scikit-learn serialized layout.protected abstract voidregisterSetters()An abstract method implemented by the derived classes that loads the layout of the binary format.protected voidregisterStringArrayField(String name, IScikitLearnLoaderStringArrayFieldSetter<ObjectType> setter)Registers a String array field for the scikit-learn serialized layout.protected voidregisterStringField(String name, IScikitLearnLoaderStringFieldSetter<ObjectType> setter)Registers a string field for the scikit-learn serialized layout.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface ai.sklearn4j.core.packaging.loaders.IScikitLearnContentLoader
duplicate
-
-
-
-
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:
getTypeNamein interfaceIScikitLearnContentLoader- 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:
loadContentin interfaceIScikitLearnContentLoader- 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.
-
registerStringField
protected void registerStringField(String name, IScikitLearnLoaderStringFieldSetter<ObjectType> setter)
Registers a string 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.
-
registerListOfNumpyArrayField
protected <ArrayType> void registerListOfNumpyArrayField(String name, IScikitLearnLoaderListOfNumpyArrayFieldSetter<ObjectType,ArrayType> setter)
Registers a list of 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.
-
registerListField
protected void registerListField(String name, IScikitLearnLoaderListFieldSetter<ObjectType> setter)
Registers a list 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.
-
registerDictionaryField
protected void registerDictionaryField(String name, IScikitLearnLoaderDictionaryFieldSetter<ObjectType> setter)
Registers a dictionary 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.
-
-