c

com.johnsnowlabs.finance.sequence_classification

FinanceDocumentMLClassifierApproach

class FinanceDocumentMLClassifierApproach extends DocumentMLClassifierApproach

Trains a model to classify documents with a Logarithmic Regression algorithm. Training data requires columns for text and their label. The result is a trained DocumentLogRegClassifierModel.

Example

Define pipeline stages to prepare the data

val document_assembler = new DocumentAssembler()
  .setInputCol("text")
  .setOutputCol("document")

val tokenizer = new Tokenizer()
  .setInputCols("document")
  .setOutputCol("token")

val normalizer = new Normalizer()
  .setInputCols("token")
  .setOutputCol("normalized")

val stopwords_cleaner = new StopWordsCleaner()
  .setInputCols("normalized")
  .setOutputCol("cleanTokens")
  .setCaseSensitive(false)

val stemmer = new Stemmer()
  .setInputCols("cleanTokens")
  .setOutputCol("stem")

Define the document classifier and fit training data to it

val logreg = new DocumentLogRegClassifierApproach()
  .setInputCols("stem")
  .setLabelCol("category")
  .setOutputCol("prediction")

val pipeline = new Pipeline().setStages(Array(
  document_assembler,
  tokenizer,
  normalizer,
  stopwords_cleaner,
  stemmer,
  logreg
))

val model = pipeline.fit(trainingData)
See also

DocumentLogRegClassifierModel for instantiated models

Linear Supertypes
DocumentMLClassifierApproach, CheckLicense, DocumentMLClassifierParams, AnnotatorApproach[DocumentMLClassifierModel], CanBeLazy, DefaultParamsWritable, MLWritable, HasOutputAnnotatorType, HasOutputAnnotationCol, HasInputAnnotationCols, Estimator[DocumentMLClassifierModel], PipelineStage, Logging, Params, Serializable, Serializable, Identifiable, AnyRef, Any
Ordering
  1. Grouped
  2. Alphabetic
  3. By Inheritance
Inherited
  1. FinanceDocumentMLClassifierApproach
  2. DocumentMLClassifierApproach
  3. CheckLicense
  4. DocumentMLClassifierParams
  5. AnnotatorApproach
  6. CanBeLazy
  7. DefaultParamsWritable
  8. MLWritable
  9. HasOutputAnnotatorType
  10. HasOutputAnnotationCol
  11. HasInputAnnotationCols
  12. Estimator
  13. PipelineStage
  14. Logging
  15. Params
  16. Serializable
  17. Serializable
  18. Identifiable
  19. AnyRef
  20. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new FinanceDocumentMLClassifierApproach()
  2. new FinanceDocumentMLClassifierApproach(uid: String)

    uid

    a unique identifier for the instantiated AnnotatorModel

Type Members

  1. type AnnotatorType = String
    Definition Classes
    HasOutputAnnotatorType

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def $[T](param: Param[T]): T
    Attributes
    protected
    Definition Classes
    Params
  4. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  5. def _fit(dataset: Dataset[_], recursiveStages: Option[PipelineModel]): DocumentMLClassifierModel
    Attributes
    protected
    Definition Classes
    AnnotatorApproach
  6. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  7. def beforeTraining(spark: SparkSession): Unit
    Definition Classes
    AnnotatorApproach
  8. def calculateNgramsUdf: UserDefinedFunction
    Definition Classes
    DocumentMLClassifierParams
  9. final def checkSchema(schema: StructType, inputAnnotatorType: String): Boolean
    Attributes
    protected
    Definition Classes
    HasInputAnnotationCols
  10. def checkValidEnvironment(spark: Option[SparkSession], scopes: Seq[String], metadata: Option[Map[String, Value]]): Unit
    Definition Classes
    CheckLicense
  11. def checkValidScope(scope: String): Unit
    Definition Classes
    CheckLicense
  12. def checkValidScopeAndEnvironment(scope: String, spark: Option[SparkSession], checkLp: Boolean, metadata: Option[Map[String, Value]]): Unit
    Definition Classes
    CheckLicense
  13. def checkValidScopesAndEnvironment(scopes: Seq[String], spark: Option[SparkSession], checkLp: Boolean, metadata: Option[Map[String, Value]]): Unit
    Definition Classes
    CheckLicense
  14. val classificationModelClass: Param[String]

    specify the classification model if it has been already trained.

    specify the classification model if it has been already trained.

    Definition Classes
    DocumentMLClassifierApproach
  15. val classificationModelPath: Param[String]

    specify the classification model if it has been already trained.

    specify the classification model if it has been already trained.

    Definition Classes
    DocumentMLClassifierApproach
  16. final def clear(param: Param[_]): FinanceDocumentMLClassifierApproach.this.type
    Definition Classes
    Params
  17. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  18. final def copy(extra: ParamMap): Estimator[DocumentMLClassifierModel]
    Definition Classes
    AnnotatorApproach → Estimator → PipelineStage → Params
  19. def copyValues[T <: Params](to: T, extra: ParamMap): T
    Attributes
    protected
    Definition Classes
    Params
  20. final def defaultCopy[T <: Params](extra: ParamMap): T
    Attributes
    protected
    Definition Classes
    Params
  21. val description: String
    Definition Classes
    DocumentMLClassifierApproach → AnnotatorApproach
  22. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  23. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  24. def explainParam(param: Param[_]): String
    Definition Classes
    Params
  25. def explainParams(): String
    Definition Classes
    Params
  26. final val extraInputCols: StringArrayParam
    Attributes
    protected
    Definition Classes
    HasInputAnnotationCols
  27. final def extractParamMap(): ParamMap
    Definition Classes
    Params
  28. final def extractParamMap(extra: ParamMap): ParamMap
    Definition Classes
    Params
  29. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  30. final def fit(dataset: Dataset[_]): DocumentMLClassifierModel
    Definition Classes
    AnnotatorApproach → Estimator
  31. def fit(dataset: Dataset[_], paramMaps: Seq[ParamMap]): Seq[DocumentMLClassifierModel]
    Definition Classes
    Estimator
    Annotations
    @Since( "2.0.0" )
  32. def fit(dataset: Dataset[_], paramMap: ParamMap): DocumentMLClassifierModel
    Definition Classes
    Estimator
    Annotations
    @Since( "2.0.0" )
  33. def fit(dataset: Dataset[_], firstParamPair: ParamPair[_], otherParamPairs: ParamPair[_]*): DocumentMLClassifierModel
    Definition Classes
    Estimator
    Annotations
    @Since( "2.0.0" ) @varargs()
  34. val fitIntercept: Param[Boolean]

    whether to fit an intercept term (Default: true)

    whether to fit an intercept term (Default: true)

    Definition Classes
    DocumentMLClassifierApproach
  35. final def get[T](param: Param[T]): Option[T]
    Definition Classes
    Params
  36. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  37. def getClassificationModelClass: String

    get the SparkML classification class to use

    get the SparkML classification class to use

    Definition Classes
    DocumentMLClassifierApproach
  38. def getClassificationModelPath: String

    get the classification model if it has been already trained.

    get the classification model if it has been already trained.

    Definition Classes
    DocumentMLClassifierApproach
  39. final def getDefault[T](param: Param[T]): Option[T]
    Definition Classes
    Params
  40. def getFitIntercept: Boolean

    get whether to fit an intercept term (Default: true)

    get whether to fit an intercept term (Default: true)

    Definition Classes
    DocumentMLClassifierApproach
  41. def getInputCols: Array[String]
    Definition Classes
    HasInputAnnotationCols
  42. def getLabelCol: String

    column with the value result we are trying to predict.

    column with the value result we are trying to predict.

    Definition Classes
    DocumentMLClassifierApproach
  43. def getLabels: Array[String]

    array to output the label in the original form.

    array to output the label in the original form.

    Definition Classes
    DocumentMLClassifierParams
  44. def getLazyAnnotator: Boolean
    Definition Classes
    CanBeLazy
  45. def getMaxIter: Int

    maximum number of iterations (Default: 10)

    maximum number of iterations (Default: 10)

    Definition Classes
    DocumentMLClassifierApproach
  46. def getMaxTokenNgramFingerprint: Int
    Definition Classes
    DocumentMLClassifierParams
  47. def getMergeChunks: Boolean

    whether to merge all chunks in a document or not (Default: false)

    whether to merge all chunks in a document or not (Default: false)

    Definition Classes
    DocumentMLClassifierParams
  48. def getMinTokenNgramFingerprint: Int
    Definition Classes
    DocumentMLClassifierParams
  49. final def getOrDefault[T](param: Param[T]): T
    Definition Classes
    Params
  50. final def getOutputCol: String
    Definition Classes
    HasOutputAnnotationCol
  51. def getParam(paramName: String): Param[Any]
    Definition Classes
    Params
  52. def getTol: Double

    get convergence tolerance after each iteration (Default: 1e-6)

    get convergence tolerance after each iteration (Default: 1e-6)

    Definition Classes
    DocumentMLClassifierApproach
  53. def getVectorizationModelPath: String

    get the vectorization model if it has been already trained.

    get the vectorization model if it has been already trained.

    Definition Classes
    DocumentMLClassifierApproach
  54. final def hasDefault[T](param: Param[T]): Boolean
    Definition Classes
    Params
  55. def hasParam(paramName: String): Boolean
    Definition Classes
    Params
  56. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  57. lazy val idf: IDF
    Definition Classes
    DocumentMLClassifierApproach
  58. def initializeLogIfNecessary(isInterpreter: Boolean, silent: Boolean): Boolean
    Attributes
    protected
    Definition Classes
    Logging
  59. def initializeLogIfNecessary(isInterpreter: Boolean): Unit
    Attributes
    protected
    Definition Classes
    Logging
  60. val inputAnnotatorTypes: Array[AnnotatorType]

    Input annotator types: TOKEN

    Input annotator types: TOKEN

    Definition Classes
    DocumentMLClassifierApproach → HasInputAnnotationCols
  61. final val inputCols: StringArrayParam
    Attributes
    protected
    Definition Classes
    HasInputAnnotationCols
  62. final def isDefined(param: Param[_]): Boolean
    Definition Classes
    Params
  63. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  64. final def isSet(param: Param[_]): Boolean
    Definition Classes
    Params
  65. def isTraceEnabled(): Boolean
    Attributes
    protected
    Definition Classes
    Logging
  66. val labelCol: Param[String]

    column with the value result we are trying to predict.

    column with the value result we are trying to predict.

    Definition Classes
    DocumentMLClassifierApproach
  67. lazy val labelEncodedCol: String
    Definition Classes
    DocumentMLClassifierApproach
  68. lazy val labelPredictedCol: String
    Definition Classes
    DocumentMLClassifierApproach
  69. lazy val labelRawCol: String
    Definition Classes
    DocumentMLClassifierApproach
  70. val labels: StringArrayParam

    array to output the label in the original form.

    array to output the label in the original form.

    Definition Classes
    DocumentMLClassifierParams
  71. val lazyAnnotator: BooleanParam
    Definition Classes
    CanBeLazy
  72. def log: Logger
    Attributes
    protected
    Definition Classes
    Logging
  73. def logDebug(msg: ⇒ String, throwable: Throwable): Unit
    Attributes
    protected
    Definition Classes
    Logging
  74. def logDebug(msg: ⇒ String): Unit
    Attributes
    protected
    Definition Classes
    Logging
  75. def logError(msg: ⇒ String, throwable: Throwable): Unit
    Attributes
    protected
    Definition Classes
    Logging
  76. def logError(msg: ⇒ String): Unit
    Attributes
    protected
    Definition Classes
    Logging
  77. def logInfo(msg: ⇒ String, throwable: Throwable): Unit
    Attributes
    protected
    Definition Classes
    Logging
  78. def logInfo(msg: ⇒ String): Unit
    Attributes
    protected
    Definition Classes
    Logging
  79. def logName: String
    Attributes
    protected
    Definition Classes
    Logging
  80. def logTrace(msg: ⇒ String, throwable: Throwable): Unit
    Attributes
    protected
    Definition Classes
    Logging
  81. def logTrace(msg: ⇒ String): Unit
    Attributes
    protected
    Definition Classes
    Logging
  82. def logWarning(msg: ⇒ String, throwable: Throwable): Unit
    Attributes
    protected
    Definition Classes
    Logging
  83. def logWarning(msg: ⇒ String): Unit
    Attributes
    protected
    Definition Classes
    Logging
  84. val maxIter: Param[Int]

    maximum number of iterations (Default: 10)

    maximum number of iterations (Default: 10)

    Definition Classes
    DocumentMLClassifierApproach
  85. val maxTokenNgram: IntParam

    the max number of tokens for Ngrams

    the max number of tokens for Ngrams

    Definition Classes
    DocumentMLClassifierParams
  86. val mergeChunks: BooleanParam

    whether to merge all chunks in a document or not (Default: false)

    whether to merge all chunks in a document or not (Default: false)

    Definition Classes
    DocumentMLClassifierParams
  87. val minTokenNgram: IntParam

    the min number of tokens for Ngrams

    the min number of tokens for Ngrams

    Definition Classes
    DocumentMLClassifierParams
  88. lazy val mlClassifier: Classifier[_, _, _] with HasMaxIter with HasTol with HasFitIntercept
    Definition Classes
    DocumentMLClassifierApproach
  89. def msgHelper(schema: StructType): String
    Attributes
    protected
    Definition Classes
    HasInputAnnotationCols
  90. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  91. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  92. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  93. def onTrained(model: DocumentMLClassifierModel, spark: SparkSession): Unit
    Definition Classes
    AnnotatorApproach
  94. val optionalInputAnnotatorTypes: Array[String]
    Definition Classes
    HasInputAnnotationCols
  95. val outputAnnotatorType: AnnotatorType

    Output annotator types: CATEGORY

    Output annotator types: CATEGORY

    Definition Classes
    DocumentMLClassifierApproach → HasOutputAnnotatorType
  96. final val outputCol: Param[String]
    Attributes
    protected
    Definition Classes
    HasOutputAnnotationCol
  97. lazy val ovrClassifier: OneVsRest
    Definition Classes
    DocumentMLClassifierApproach
  98. lazy val params: Array[Param[_]]
    Definition Classes
    Params
  99. def save(path: String): Unit
    Definition Classes
    MLWritable
    Annotations
    @Since( "1.6.0" ) @throws( ... )
  100. final def set(paramPair: ParamPair[_]): FinanceDocumentMLClassifierApproach.this.type
    Attributes
    protected
    Definition Classes
    Params
  101. final def set(param: String, value: Any): FinanceDocumentMLClassifierApproach.this.type
    Attributes
    protected
    Definition Classes
    Params
  102. final def set[T](param: Param[T], value: T): FinanceDocumentMLClassifierApproach.this.type
    Definition Classes
    Params
  103. def setClassificationModelClass(value: String): FinanceDocumentMLClassifierApproach.this.type

    set the SparkML classification class to use

    set the SparkML classification class to use

    Definition Classes
    DocumentMLClassifierApproach
  104. def setClassificationModelPath(value: String): FinanceDocumentMLClassifierApproach.this.type

    set the classification model if it has been already trained.

    set the classification model if it has been already trained.

    Definition Classes
    DocumentMLClassifierApproach
  105. final def setDefault(paramPairs: ParamPair[_]*): FinanceDocumentMLClassifierApproach.this.type
    Attributes
    protected
    Definition Classes
    Params
  106. final def setDefault[T](param: Param[T], value: T): FinanceDocumentMLClassifierApproach.this.type
    Attributes
    protected[org.apache.spark.ml]
    Definition Classes
    Params
  107. def setExtraInputCols(value: Array[String]): FinanceDocumentMLClassifierApproach.this.type
    Definition Classes
    HasInputAnnotationCols
  108. def setFitIntercept(value: Boolean): FinanceDocumentMLClassifierApproach.this.type

    set whether to fit an intercept term (Default: true)

    set whether to fit an intercept term (Default: true)

    Definition Classes
    DocumentMLClassifierApproach
  109. final def setInputCols(value: String*): FinanceDocumentMLClassifierApproach.this.type
    Definition Classes
    HasInputAnnotationCols
  110. def setInputCols(value: Array[String]): FinanceDocumentMLClassifierApproach.this.type
    Definition Classes
    HasInputAnnotationCols
  111. def setLabelCol(value: String): FinanceDocumentMLClassifierApproach.this.type

    column with the value result we are trying to predict.

    column with the value result we are trying to predict.

    Definition Classes
    DocumentMLClassifierApproach
  112. def setLabels(value: Array[String]): FinanceDocumentMLClassifierApproach.this.type

    array to output the label in the original form.

    array to output the label in the original form.

    Definition Classes
    DocumentMLClassifierParams
  113. def setLazyAnnotator(value: Boolean): FinanceDocumentMLClassifierApproach.this.type
    Definition Classes
    CanBeLazy
  114. def setMaxIter(value: Int): FinanceDocumentMLClassifierApproach.this.type

    maximum number of iterations (Default: 10)

    maximum number of iterations (Default: 10)

    Definition Classes
    DocumentMLClassifierApproach
  115. def setMaxTokenNgram(value: Int): FinanceDocumentMLClassifierApproach.this.type
    Definition Classes
    DocumentMLClassifierApproach
  116. def setMaxTokenNgramFingerprint(value: Int): FinanceDocumentMLClassifierApproach.this.type
    Definition Classes
    DocumentMLClassifierParams
  117. def setMergeChunks(value: Boolean): FinanceDocumentMLClassifierApproach.this.type

    whether to merge all chunks in a document or not (Default: false)

    whether to merge all chunks in a document or not (Default: false)

    Definition Classes
    DocumentMLClassifierParams
  118. def setMinTokenNgram(value: Int): FinanceDocumentMLClassifierApproach.this.type
    Definition Classes
    DocumentMLClassifierApproach
  119. def setMinTokenNgramFingerprint(value: Int): FinanceDocumentMLClassifierApproach.this.type
    Definition Classes
    DocumentMLClassifierParams
  120. final def setOutputCol(value: String): FinanceDocumentMLClassifierApproach.this.type
    Definition Classes
    HasOutputAnnotationCol
  121. def setTol(value: Double): FinanceDocumentMLClassifierApproach.this.type

    set convergence tolerance after each iteration (Default: 1e-6)

    set convergence tolerance after each iteration (Default: 1e-6)

    Definition Classes
    DocumentMLClassifierApproach
  122. def setVectorizationModelPath(value: String): FinanceDocumentMLClassifierApproach.this.type

    set the vectorization model if it has been already trained.

    set the vectorization model if it has been already trained.

    Definition Classes
    DocumentMLClassifierApproach
  123. lazy val sidx: StringIndexer
    Definition Classes
    DocumentMLClassifierApproach
  124. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  125. lazy val tf: HashingTF
    Definition Classes
    DocumentMLClassifierApproach
  126. lazy val tfCol: String
    Definition Classes
    DocumentMLClassifierApproach
  127. lazy val tfidfCol: String
    Definition Classes
    DocumentMLClassifierApproach
  128. def toString(): String
    Definition Classes
    Identifiable → AnyRef → Any
  129. lazy val tokenAnnotationCol: String
    Definition Classes
    DocumentMLClassifierApproach
  130. lazy val tokenRawCol: String
    Definition Classes
    DocumentMLClassifierApproach
  131. val tol: Param[Double]

    convergence tolerance after each iteration (Default: 1e-6)

    convergence tolerance after each iteration (Default: 1e-6)

    Definition Classes
    DocumentMLClassifierApproach
  132. def train(dataset: Dataset[_], recursivePipeline: Option[PipelineModel]): FinanceDocumentMLClassifierModel
    Definition Classes
    FinanceDocumentMLClassifierApproachDocumentMLClassifierApproach → AnnotatorApproach
  133. final def transformSchema(schema: StructType): StructType
    Definition Classes
    AnnotatorApproach → PipelineStage
  134. def transformSchema(schema: StructType, logging: Boolean): StructType
    Attributes
    protected
    Definition Classes
    PipelineStage
    Annotations
    @DeveloperApi()
  135. val uid: String
  136. def validate(schema: StructType): Boolean
    Attributes
    protected
    Definition Classes
    AnnotatorApproach
  137. val vectorizationModelPath: Param[String]

    specify the vectorization model if it has been already trained.

    specify the vectorization model if it has been already trained.

    Definition Classes
    DocumentMLClassifierApproach
  138. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  139. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  140. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  141. def write: MLWriter
    Definition Classes
    DefaultParamsWritable → MLWritable

Inherited from CheckLicense

Inherited from AnnotatorApproach[DocumentMLClassifierModel]

Inherited from CanBeLazy

Inherited from DefaultParamsWritable

Inherited from MLWritable

Inherited from HasOutputAnnotatorType

Inherited from HasOutputAnnotationCol

Inherited from HasInputAnnotationCols

Inherited from Estimator[DocumentMLClassifierModel]

Inherited from PipelineStage

Inherited from Logging

Inherited from Params

Inherited from Serializable

Inherited from Serializable

Inherited from Identifiable

Inherited from AnyRef

Inherited from Any

Parameters

Annotator types

Required input and expected output annotator types

Members

Parameter setters

Parameter getters