Packages

p

com.johnsnowlabs.nlp.annotators

generic_classifier

package generic_classifier

Ordering
  1. Alphabetic
Visibility
  1. Public
  2. All

Type Members

  1. class GenericClassifierApproach extends AnnotatorApproach[GenericClassifierModel] with HandleExceptionParams with CheckLicense

    Trains a TensorFlow model for generic classification of feature vectors.

    Trains a TensorFlow model for generic classification of feature vectors. It takes FEATURE_VECTOR annotations from FeaturesAssembler as input, classifies them and outputs CATEGORY annotations. Please see the Parameters section for required training parameters.

    For a more extensive example please see the Spark NLP Workshop.

    Example

    val features_asm = new FeaturesAssembler()
      .setInputCols(Array("feature_1", "feature_2", "...", "feature_n"))
      .setOutputCol("features")
    
    val gen_clf = new GenericClassifierApproach()
      .setLabelColumn("target")
      .setInputCols("features")
      .setOutputCol("prediction")
      .setModelFile("/path/to/graph_file.pb")
      .setEpochsNumber(50)
      .setBatchSize(100)
      .setFeatureScaling("zscore")
      .setlearningRate(0.001f)
      .setFixImbalance(true)
      .setOutputLogsPath("logs")
      .setValidationSplit(0.2f) // keep 20% of the data for validation purposes
    
    val pipeline = new Pipeline().setStages(Array(
      features_asm,
      gen_clf
    ))
    
    val clf_model = pipeline.fit(data)
    See also

    GenericClassifierModel for the trained model

  2. class GenericClassifierDataEncoder extends Serializable
    Annotations
    @SerialVersionUID()
  3. class GenericClassifierModel extends AnnotatorModel[GenericClassifierModel] with HasStorageRef with ParamsAndFeaturesWritable with WriteTensorflowModel with HasSimpleAnnotate[GenericClassifierModel] with HandleExceptionParams with HasSafeAnnotate[GenericClassifierModel] with CheckLicense

    Creates a generic single-label classifier which uses pre-generated Tensorflow graphs.

    Creates a generic single-label classifier which uses pre-generated Tensorflow graphs. The model operates on FEATURE_VECTOR annotations which can be produced using FeatureAssembler. Requires the FeaturesAssembler to create the input.

    See also

    GenericClassifierApproach for an example and on how to define your own model

  4. trait ReadablePretrainedGenericClassifier[T <: GenericClassifierModel] extends ParamsAndFeaturesReadable[T] with HasPretrained[T]
  5. trait ReadsGenericClassifierGraph[T <: GenericClassifierModel] extends ParamsAndFeaturesReadable[T] with ReadTensorflowModel

Ungrouped