การจำแนกประเภทข้อความ

Introduction to Spark SQL in Python

Mark Plutowski

Data Scientist

การทำนายคำท้าย

Introduction to Spark SQL in Python

ลูกศรแสดงลำดับ

Introduction to Spark SQL in Python

คำท้าย

Introduction to Spark SQL in Python

วงเล็บคำท้าย

Introduction to Spark SQL in Python

สับเปลี่ยน 1

Introduction to Spark SQL in Python

สับเปลี่ยน 2

Introduction to Spark SQL in Python

เพลง

Introduction to Spark SQL in Python

วิดีโอ

Introduction to Spark SQL in Python

การเลือกข้อมูล

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))
Introduction to Spark SQL in Python

การรวมข้อมูลบวกและลบเข้าด้วยกัน

df_examples = df_true.union(df_false)
Introduction to Spark SQL in Python

การแบ่งข้อมูลเป็นชุด training และ evaluation

df_train, df_eval = df_examples.randomSplit((0.60, 0.40), 42)
Introduction to Spark SQL in Python

การฝึกโมเดล

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)
Introduction to Spark SQL in Python

มาฝึกกันเถอะ!

Introduction to Spark SQL in Python

Preparing Video For Download...