Clasificarea textului

Introducere în Spark SQL în Python

Mark Plutowski

Data Scientist

Predicția cuvântului final

Introducere în Spark SQL în Python

Săgeată secvență

Introducere în Spark SQL în Python

Cuvânt final

Introducere în Spark SQL în Python

Paranteză cuvânt final

Introducere în Spark SQL în Python

Amestecare 1

Introducere în Spark SQL în Python

Amestecare 2

Introducere în Spark SQL în Python

Melodii

Introducere în Spark SQL în Python

Videoclipuri

Introducere în Spark SQL în Python

Selectarea datelor

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))
Introducere în Spark SQL în Python

Combinarea datelor pozitive și negative

df_examples = df_true.union(df_false)
Introducere în Spark SQL în Python

Împărțirea datelor în seturi de antrenament și evaluare

df_train, df_eval = df_examples.randomSplit((0.60, 0.40), 42)
Introducere în Spark SQL în Python

Antrenarea modelului

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)
Introducere în Spark SQL în Python

Să exersăm!

Introducere în Spark SQL în Python

Preparing Video For Download...