テキスト分類

Pythonで学ぶ Spark SQL 入門

Mark Plutowski

Data Scientist

語尾予測

Pythonで学ぶ Spark SQL 入門

シーケンス矢印

Pythonで学ぶ Spark SQL 入門

語尾

Pythonで学ぶ Spark SQL 入門

語尾ブラケット

Pythonで学ぶ Spark SQL 入門

シャッフル 1

Pythonで学ぶ Spark SQL 入門

シャッフル 2

Pythonで学ぶ Spark SQL 入門

楽曲

Pythonで学ぶ Spark SQL 入門

動画

Pythonで学ぶ Spark SQL 入門

データの選択

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))
Pythonで学ぶ Spark SQL 入門

正例・負例の結合

df_examples = df_true.union(df_false)
Pythonで学ぶ Spark SQL 入門

学習用と評価用への分割

df_train, df_eval = df_examples.randomSplit((0.60, 0.40), 42)
Pythonで学ぶ Spark SQL 入門

学習

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)
Pythonで学ぶ Spark SQL 入門

Let's practice!

Pythonで学ぶ Spark SQL 入門

Preparing Video For Download...