nlp_sentiment_dl: Spark NLP SentimentDLApproach Sentiment detection Deep...

View source: R/sentiment-dl.R

nlp_sentiment_dlR Documentation

Spark NLP SentimentDLApproach Sentiment detection Deep Learning annotator

Description

Multi-class sentiment analysis annotator. SentimentDL is an annotator for multi-class sentiment analysis. This annotator comes with 2 available pre-trained models trained on IMDB and Twitter datasets NOTE: This annotator accepts a label column of a single item in either type of String, Int, Float, or Double. NOTE: UniversalSentenceEncoder and SentenceEmbeddings can be used for the inputCol

Usage

nlp_sentiment_dl(
  x,
  input_cols,
  output_col,
  label_col = NULL,
  max_epochs = NULL,
  lr = NULL,
  batch_size = NULL,
  dropout = NULL,
  verbose = NULL,
  threshold = NULL,
  threshold_label = NULL,
  validation_split = NULL,
  enable_output_logs = NULL,
  output_logs_path = NULL,
  uid = random_string("sentiment_dl_")
)

Arguments

x

A spark_connection, ml_pipeline, or a tbl_spark.

input_cols

Input columns. String array.

output_col

Output column. String.

label_col

If DatasetPath is not provided, this seq of Annotation type of column should have labeled data per token (string)

max_epochs

Maximum number of epochs to train (integer)

lr

Initial learning rate (float)

batch_size

Batch size for training (integer)

dropout

Dropout coefficient (float)

verbose

Verbosity level during training (integer)

threshold

The minimum threshold for the final result otheriwse it will be either neutral or the value set in thresholdLabel

threshold_label

In case the score is less than threshold, what should be the label. Default is neutral.

validation_split

Choose the proportion of training dataset to be validated against the model on each Epoch. The value should be between 0.0 and 1.0 and by default it is 0.0 and off (float)

enable_output_logs

whether to enable the TensorFlow output logs (boolean)

output_logs_path

path for the output logs

uid

A character string used to uniquely identify the ML estimator.

Details

See https://nlp.johnsnowlabs.com/docs/en/annotators#sentimentdl

Value

The object returned depends on the class of x.

  • spark_connection: When x is a spark_connection, the function returns an instance of a ml_estimator object. The object contains a pointer to a Spark Estimator object and can be used to compose Pipeline objects.

  • ml_pipeline: When x is a ml_pipeline, the function returns a ml_pipeline with the NLP estimator appended to the pipeline.

  • tbl_spark: When x is a tbl_spark, an estimator is constructed then immediately fit with the input tbl_spark, returning an NLP model.

When x is a spark_connection the function returns a SentimentDLApproach estimator. When x is a ml_pipeline the pipeline with the SentimentDLApproach added. When x is a tbl_spark a transformed tbl_spark (note that the Dataframe passed in must have the input_cols specified).


r-spark/sparknlp documentation built on Oct. 15, 2022, 10:50 a.m.