Clasificación de texto

Introducción a Spark SQL en Python

Mark Plutowski

Data Scientist

Predicción de endword

Introducción a Spark SQL en Python

Flecha de secuencia

Introducción a Spark SQL en Python

Endword

Introducción a Spark SQL en Python

Corchete de endword

Introducción a Spark SQL en Python

Barajar 1

Introducción a Spark SQL en Python

Barajar 2

Introducción a Spark SQL en Python

Canciones

Introducción a Spark SQL en Python

Vídeos

Introducción a Spark SQL en Python

Selección de datos

df_true = df.where("endword in ('she', 'he', 'hers', 'his', 'her', 'him')")\
            .withColumn('label', lit(1))

df_false = df.where("endword not in ('she', 'he', 'hers', 'his', 'her', 'him')")\
           .withColumn('label', lit(0))
Introducción a Spark SQL en Python

Combinar datos positivos y negativos

df_examples = df_true.union(df_false)
Introducción a Spark SQL en Python

Dividir en train y eval

df_train, df_eval = df_examples.randomSplit((0.60, 0.40), 42)
Introducción a Spark SQL en Python

Entrenamiento

from pyspark.ml.classification import LogisticRegression

logistic = LogisticRegression(maxIter=50, regParam=0.6, elasticNetParam=0.3)
model = logistic.fit(df_train)
print("Training iterations: ", model.summary.totalIterations)
Introducción a Spark SQL en Python

¡Vamos a practicar!

Introducción a Spark SQL en Python

Preparing Video For Download...