텍스트 분류

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 입문

연습해 봅시다!

Python에서 Spark SQL 입문

Preparing Video For Download...