Packages

class AssertionDLModel extends AnnotatorModel[AssertionDLModel] with WriteTensorflowModel with HasStorageRef with HasSimpleAnnotate[AssertionDLModel] with ParamsAndFeaturesWritable with Licensed

This is a main class in AssertionDL family. A Deep Learning based approach is used to extract Assertion Status from extracted entities and text. AssertionDLModel requires DOCUMENT, CHUNK and WORD_EMBEDDINGS type annotator inputs, which can be obtained by e.g a DocumentAssembler, NerConverter and WordEmbeddingsModel. The result is an assertion status annotation for each recognized entity. Possible values include “present”, “absent”, “hypothetical”, “conditional”, “associated_with_other_person” etc.

For pretrained models please see the Models Hub for available models.

Example

Define pipeline stages to extract NER chunks first

val data = Seq(
  "Patient with severe fever and sore throat",
  "Patient shows no stomach pain",
  "She was maintained on an epidural and PCA for pain control.").toDF("text")
val documentAssembler = new DocumentAssembler().setInputCol("text").setOutputCol("document")
val sentenceDetector = new SentenceDetector().setInputCols("document").setOutputCol("sentence")
val tokenizer = new Tokenizer().setInputCols("sentence").setOutputCol("token")
val embeddings = WordEmbeddingsModel.pretrained("embeddings_clinical", "en", "clinical/models")
  .setOutputCol("embeddings")
val nerModel = MedicalNerModel.pretrained("ner_clinical", "en", "clinical/models")
  .setInputCols("sentence", "token", "embeddings").setOutputCol("ner")
val nerConverter = new NerConverter().setInputCols("sentence", "token", "ner").setOutputCol("ner_chunk")

Then a pretrained AssertionDLModel is used to extract the assertion status

val clinicalAssertion = AssertionDLModel.pretrained("assertion_dl", "en", "clinical/models")
  .setInputCols("sentence", "ner_chunk", "embeddings")
  .setOutputCol("assertion")

val assertionPipeline = new Pipeline().setStages(Array(
  documentAssembler,
  sentenceDetector,
  tokenizer,
  embeddings,
  nerModel,
  nerConverter,
  clinicalAssertion
))

val assertionModel = assertionPipeline.fit(data)

Show results

val result = assertionModel.transform(data)
result.selectExpr("ner_chunk.result", "assertion.result").show(3, truncate=false)
+--------------------------------+--------------------------------+
|result                          |result                          |
+--------------------------------+--------------------------------+
|[severe fever, sore throat]     |[present, present]              |
|[stomach pain]                  |[absent]                        |
|[an epidural, PCA, pain control]|[present, present, hypothetical]|
+--------------------------------+--------------------------------+
See also

AssertionDLApproach for training a custom AssertionDLModel

AssertionLogRegModel for non deep learning based extraction

Linear Supertypes
Licensed, HasSimpleAnnotate[AssertionDLModel], HasStorageRef, WriteTensorflowModel, AnnotatorModel[AssertionDLModel], CanBeLazy, RawAnnotator[AssertionDLModel], HasOutputAnnotationCol, HasInputAnnotationCols, HasOutputAnnotatorType, ParamsAndFeaturesWritable, HasFeatures, DefaultParamsWritable, MLWritable, Model[AssertionDLModel], Transformer, PipelineStage, Logging, Params, Serializable, Serializable, Identifiable, AnyRef, Any
Ordering
  1. Grouped
  2. Alphabetic
  3. By Inheritance
Inherited
  1. AssertionDLModel
  2. Licensed
  3. HasSimpleAnnotate
  4. HasStorageRef
  5. WriteTensorflowModel
  6. AnnotatorModel
  7. CanBeLazy
  8. RawAnnotator
  9. HasOutputAnnotationCol
  10. HasInputAnnotationCols
  11. HasOutputAnnotatorType
  12. ParamsAndFeaturesWritable
  13. HasFeatures
  14. DefaultParamsWritable
  15. MLWritable
  16. Model
  17. Transformer
  18. PipelineStage
  19. Logging
  20. Params
  21. Serializable
  22. Serializable
  23. Identifiable
  24. AnyRef
  25. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

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

    uid

    a unique identifier for the instantiated AnnotatorModel

Type Members

  1. type AnnotationContent = Seq[Row]
    Attributes
    protected
    Definition Classes
    AnnotatorModel
  2. 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. def $$[T](feature: StructFeature[T]): T
    Attributes
    protected
    Definition Classes
    HasFeatures
  5. def $$[K, V](feature: MapFeature[K, V]): Map[K, V]
    Attributes
    protected
    Definition Classes
    HasFeatures
  6. def $$[T](feature: SetFeature[T]): Set[T]
    Attributes
    protected
    Definition Classes
    HasFeatures
  7. def $$[T](feature: ArrayFeature[T]): Array[T]
    Attributes
    protected
    Definition Classes
    HasFeatures
  8. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  9. def _transform(dataset: Dataset[_], recursivePipeline: Option[PipelineModel]): DataFrame
    Attributes
    protected
    Definition Classes
    AnnotatorModel
  10. def afterAnnotate(dataset: DataFrame): DataFrame
    Attributes
    protected
    Definition Classes
    AnnotatorModel
  11. def annotate(annotations: Seq[Annotation]): Seq[Annotation]

    This is main point of interest.

    This is main point of interest. It annotates the input dataset applying properties of the class above This method utilises chunk groups, word piece embeddings and conversion to chunk indexes

    annotations

    a sequence of Annotations

    returns

    a sequence of projected Annotations

    Definition Classes
    AssertionDLModel → HasSimpleAnnotate
  12. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  13. val batchSize: IntParam

    Size of every batch

  14. def beforeAnnotate(dataset: Dataset[_]): Dataset[_]

    This method validates the dataset before annotation

    This method validates the dataset before annotation

    dataset

    a collection of inputs to validate

    returns

    a Dataset after validation

    Attributes
    protected
    Definition Classes
    AssertionDLModel → AnnotatorModel
  15. final def checkSchema(schema: StructType, inputAnnotatorType: String): Boolean
    Attributes
    protected
    Definition Classes
    HasInputAnnotationCols
  16. val classes: StringArrayParam

    List of internal copies of classes used to train for Python

  17. final def clear(param: Param[_]): AssertionDLModel.this.type
    Definition Classes
    Params
  18. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  19. val configProtoBytes: IntArrayParam

    ConfigProto from tensorflow, serialized into byte array.

    ConfigProto from tensorflow, serialized into byte array. Get with config_proto.SerializeToString

  20. def copy(extra: ParamMap): AssertionDLModel

    requirement for annotators copies

    requirement for annotators copies

    Definition Classes
    AssertionDLModel → RawAnnotator → Model → Transformer → PipelineStage → Params
  21. def copyValues[T <: Params](to: T, extra: ParamMap): T
    Attributes
    protected
    Definition Classes
    Params
  22. def createDatabaseConnection(database: Name): RocksDBConnection
    Definition Classes
    HasStorageRef
  23. val datasetParams: StructFeature[DatasetEncoderParams]

    Collection of Parameters, which are used by method annotate()

  24. final def defaultCopy[T <: Params](extra: ParamMap): T
    Attributes
    protected
    Definition Classes
    Params
  25. def dfAnnotate: UserDefinedFunction
    Definition Classes
    HasSimpleAnnotate
  26. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  27. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  28. def explainParam(param: Param[_]): String
    Definition Classes
    Params
  29. def explainParams(): String
    Definition Classes
    Params
  30. def extraValidate(structType: StructType): Boolean
    Attributes
    protected
    Definition Classes
    RawAnnotator
  31. def extraValidateMsg: String
    Attributes
    protected
    Definition Classes
    RawAnnotator
  32. final def extractParamMap(): ParamMap
    Definition Classes
    Params
  33. final def extractParamMap(extra: ParamMap): ParamMap
    Definition Classes
    Params
  34. val features: ArrayBuffer[Feature[_, _, _]]
    Definition Classes
    HasFeatures
  35. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  36. def get[T](feature: StructFeature[T]): Option[T]
    Attributes
    protected
    Definition Classes
    HasFeatures
  37. def get[K, V](feature: MapFeature[K, V]): Option[Map[K, V]]
    Attributes
    protected
    Definition Classes
    HasFeatures
  38. def get[T](feature: SetFeature[T]): Option[Set[T]]
    Attributes
    protected
    Definition Classes
    HasFeatures
  39. def get[T](feature: ArrayFeature[T]): Option[Array[T]]
    Attributes
    protected
    Definition Classes
    HasFeatures
  40. final def get[T](param: Param[T]): Option[T]
    Definition Classes
    Params
  41. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  42. def getClasses: Array[String]

    get the tags used to trained this NerDLModel

  43. def getConfigProtoBytes: Option[Array[Byte]]

    ConfigProto from tensorflow, serialized into byte array.

    ConfigProto from tensorflow, serialized into byte array. Get with config_proto.SerializeToString

  44. final def getDefault[T](param: Param[T]): Option[T]
    Definition Classes
    Params
  45. def getIncludeConfidence: Boolean

    whether to include confidence scores in annotation metadata

  46. def getInputCols: Array[String]
    Definition Classes
    HasInputAnnotationCols
  47. def getLazyAnnotator: Boolean
    Definition Classes
    CanBeLazy
  48. final def getOrDefault[T](param: Param[T]): T
    Definition Classes
    Params
  49. final def getOutputCol: String
    Definition Classes
    HasOutputAnnotationCol
  50. def getParam(paramName: String): Param[Any]
    Definition Classes
    Params
  51. def getStorageRef: String
    Definition Classes
    HasStorageRef
  52. final def hasDefault[T](param: Param[T]): Boolean
    Definition Classes
    Params
  53. def hasParam(paramName: String): Boolean
    Definition Classes
    Params
  54. def hasParent: Boolean
    Definition Classes
    Model
  55. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  56. val includeConfidence: BooleanParam

    whether to include confidence scores in annotation metadata (Default: false)

  57. def initializeLogIfNecessary(isInterpreter: Boolean, silent: Boolean): Boolean
    Attributes
    protected
    Definition Classes
    Logging
  58. def initializeLogIfNecessary(isInterpreter: Boolean): Unit
    Attributes
    protected
    Definition Classes
    Logging
  59. val inputAnnotatorTypes: Array[String]

    Input annotator types: DOCUMENT, CHUNK, WORD_EMBEDDINGS

    Input annotator types: DOCUMENT, CHUNK, WORD_EMBEDDINGS

    Definition Classes
    AssertionDLModel → HasInputAnnotationCols
  60. final val inputCols: StringArrayParam
    Attributes
    protected
    Definition Classes
    HasInputAnnotationCols
  61. final def isDefined(param: Param[_]): Boolean
    Definition Classes
    Params
  62. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  63. final def isSet(param: Param[_]): Boolean
    Definition Classes
    Params
  64. def isTraceEnabled(): Boolean
    Attributes
    protected
    Definition Classes
    Logging
  65. val lazyAnnotator: BooleanParam
    Definition Classes
    CanBeLazy
  66. def log: Logger
    Attributes
    protected
    Definition Classes
    Logging
  67. def logDebug(msg: ⇒ String, throwable: Throwable): Unit
    Attributes
    protected
    Definition Classes
    Logging
  68. def logDebug(msg: ⇒ String): Unit
    Attributes
    protected
    Definition Classes
    Logging
  69. def logError(msg: ⇒ String, throwable: Throwable): Unit
    Attributes
    protected
    Definition Classes
    Logging
  70. def logError(msg: ⇒ String): Unit
    Attributes
    protected
    Definition Classes
    Logging
  71. def logInfo(msg: ⇒ String, throwable: Throwable): Unit
    Attributes
    protected
    Definition Classes
    Logging
  72. def logInfo(msg: ⇒ String): Unit
    Attributes
    protected
    Definition Classes
    Logging
  73. def logName: String
    Attributes
    protected
    Definition Classes
    Logging
  74. def logTrace(msg: ⇒ String, throwable: Throwable): Unit
    Attributes
    protected
    Definition Classes
    Logging
  75. def logTrace(msg: ⇒ String): Unit
    Attributes
    protected
    Definition Classes
    Logging
  76. def logWarning(msg: ⇒ String, throwable: Throwable): Unit
    Attributes
    protected
    Definition Classes
    Logging
  77. def logWarning(msg: ⇒ String): Unit
    Attributes
    protected
    Definition Classes
    Logging
  78. val maxSentLen: IntParam

    Max possible length of a sentence (Default: 256)

  79. def model: TensorflowAssertion

    Tensorflow model for the AssertionDLModel.

    Tensorflow model for the AssertionDLModel. This is used to generate the predictions.

  80. def msgHelper(schema: StructType): String
    Attributes
    protected
    Definition Classes
    HasInputAnnotationCols
  81. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  82. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  83. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  84. def onWrite(path: String, spark: SparkSession): Unit
    Definition Classes
    AssertionDLModel → ParamsAndFeaturesWritable
  85. val outputAnnotatorType: AnnotatorType

    Output annotator types: ASSERTION

    Output annotator types: ASSERTION

    Definition Classes
    AssertionDLModel → HasOutputAnnotatorType
  86. final val outputCol: Param[String]
    Attributes
    protected
    Definition Classes
    HasOutputAnnotationCol
  87. lazy val params: Array[Param[_]]
    Definition Classes
    Params
  88. var parent: Estimator[AssertionDLModel]
    Definition Classes
    Model
  89. def save(path: String): Unit
    Definition Classes
    MLWritable
    Annotations
    @Since( "1.6.0" ) @throws( ... )
  90. def set[T](feature: StructFeature[T], value: T): AssertionDLModel.this.type
    Attributes
    protected
    Definition Classes
    HasFeatures
  91. def set[K, V](feature: MapFeature[K, V], value: Map[K, V]): AssertionDLModel.this.type
    Attributes
    protected
    Definition Classes
    HasFeatures
  92. def set[T](feature: SetFeature[T], value: Set[T]): AssertionDLModel.this.type
    Attributes
    protected
    Definition Classes
    HasFeatures
  93. def set[T](feature: ArrayFeature[T], value: Array[T]): AssertionDLModel.this.type
    Attributes
    protected
    Definition Classes
    HasFeatures
  94. final def set(paramPair: ParamPair[_]): AssertionDLModel.this.type
    Attributes
    protected
    Definition Classes
    Params
  95. final def set(param: String, value: Any): AssertionDLModel.this.type
    Attributes
    protected
    Definition Classes
    Params
  96. final def set[T](param: Param[T], value: T): AssertionDLModel.this.type
    Definition Classes
    Params
  97. def setBatchSize(size: Int): AssertionDLModel.this.type

    Size of every batch

  98. def setConfigProtoBytes(bytes: Array[Int]): AssertionDLModel

    ConfigProto from tensorflow, serialized into byte array.

    ConfigProto from tensorflow, serialized into byte array. Get with config_proto.SerializeToString

  99. def setDatasetParams(params: DatasetEncoderParams): AssertionDLModel

    Collection of Parameters, which are used by method annotate()

  100. def setDefault[T](feature: StructFeature[T], value: () ⇒ T): AssertionDLModel.this.type
    Attributes
    protected
    Definition Classes
    HasFeatures
  101. def setDefault[K, V](feature: MapFeature[K, V], value: () ⇒ Map[K, V]): AssertionDLModel.this.type
    Attributes
    protected
    Definition Classes
    HasFeatures
  102. def setDefault[T](feature: SetFeature[T], value: () ⇒ Set[T]): AssertionDLModel.this.type
    Attributes
    protected
    Definition Classes
    HasFeatures
  103. def setDefault[T](feature: ArrayFeature[T], value: () ⇒ Array[T]): AssertionDLModel.this.type
    Attributes
    protected
    Definition Classes
    HasFeatures
  104. final def setDefault(paramPairs: ParamPair[_]*): AssertionDLModel.this.type
    Attributes
    protected
    Definition Classes
    Params
  105. final def setDefault[T](param: Param[T], value: T): AssertionDLModel.this.type
    Attributes
    protected
    Definition Classes
    Params
  106. def setIncludeConfidence(value: Boolean): AssertionDLModel.this.type

    whether to include confidence scores in annotation metadata

  107. final def setInputCols(value: String*): AssertionDLModel.this.type
    Definition Classes
    HasInputAnnotationCols
  108. final def setInputCols(value: Array[String]): AssertionDLModel.this.type
    Definition Classes
    HasInputAnnotationCols
  109. def setLazyAnnotator(value: Boolean): AssertionDLModel.this.type
    Definition Classes
    CanBeLazy
  110. def setMaxSentLen(len: Int): AssertionDLModel.this.type

    Max possible length of a sentence.

  111. final def setOutputCol(value: String): AssertionDLModel.this.type
    Definition Classes
    HasOutputAnnotationCol
  112. def setParent(parent: Estimator[AssertionDLModel]): AssertionDLModel
    Definition Classes
    Model
  113. def setStorageRef(value: String): AssertionDLModel.this.type
    Definition Classes
    HasStorageRef
  114. def setTensorflow(tf: TensorflowWrapper): AssertionDLModel
  115. val storageRef: Param[String]
    Definition Classes
    HasStorageRef
  116. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  117. var tensorflow: TensorflowWrapper
  118. def toString(): String
    Definition Classes
    Identifiable → AnyRef → Any
  119. final def transform(dataset: Dataset[_]): DataFrame
    Definition Classes
    AnnotatorModel → Transformer
  120. def transform(dataset: Dataset[_], paramMap: ParamMap): DataFrame
    Definition Classes
    Transformer
    Annotations
    @Since( "2.0.0" )
  121. def transform(dataset: Dataset[_], firstParamPair: ParamPair[_], otherParamPairs: ParamPair[_]*): DataFrame
    Definition Classes
    Transformer
    Annotations
    @Since( "2.0.0" ) @varargs()
  122. final def transformSchema(schema: StructType): StructType
    Definition Classes
    RawAnnotator → PipelineStage
  123. def transformSchema(schema: StructType, logging: Boolean): StructType
    Attributes
    protected
    Definition Classes
    PipelineStage
    Annotations
    @DeveloperApi()
  124. val uid: String
    Definition Classes
    AssertionDLModel → Identifiable
  125. def validate(schema: StructType): Boolean
    Attributes
    protected
    Definition Classes
    RawAnnotator
  126. def validateStorageRef(dataset: Dataset[_], inputCols: Array[String], annotatorType: String): Unit
    Definition Classes
    HasStorageRef
  127. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  128. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  129. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  130. def wrapColumnMetadata(col: Column): Column
    Attributes
    protected
    Definition Classes
    RawAnnotator
  131. def write: MLWriter
    Definition Classes
    ParamsAndFeaturesWritable → DefaultParamsWritable → MLWritable
  132. def writeTensorflowHub(path: String, tfPath: String, spark: SparkSession, suffix: String): Unit
    Definition Classes
    WriteTensorflowModel
  133. def writeTensorflowModel(path: String, spark: SparkSession, tensorflow: TensorflowWrapper, suffix: String, filename: String, configProtoBytes: Option[Array[Byte]]): Unit
    Definition Classes
    WriteTensorflowModel
  134. def writeTensorflowModelV2(path: String, spark: SparkSession, tensorflow: TensorflowWrapper, suffix: String, filename: String, configProtoBytes: Option[Array[Byte]]): Unit
    Definition Classes
    WriteTensorflowModel

Inherited from Licensed

Inherited from HasSimpleAnnotate[AssertionDLModel]

Inherited from HasStorageRef

Inherited from WriteTensorflowModel

Inherited from AnnotatorModel[AssertionDLModel]

Inherited from CanBeLazy

Inherited from RawAnnotator[AssertionDLModel]

Inherited from HasOutputAnnotationCol

Inherited from HasInputAnnotationCols

Inherited from HasOutputAnnotatorType

Inherited from ParamsAndFeaturesWritable

Inherited from HasFeatures

Inherited from DefaultParamsWritable

Inherited from MLWritable

Inherited from Model[AssertionDLModel]

Inherited from Transformer

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