LoslegenKostenlos loslegen

Predict test data

A fitted logistic model df_fitted is available. A dataframe df_testset is available containing test data for this model. A variable fields is available, containing the list ['prediction', 'label', 'endword', 'doc', 'probability']; this is used to specify which prediction fields to print.

Diese Übung ist Teil des Kurses

Introduction to Spark SQL in Python

Kurs anzeigen

Anleitung zur Übung

  • Apply the model to the data in df_testset.
  • Print "incorrect" if prediction does not match label.

Interaktive Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

# Apply the model to the test data
predictions = df_fitted.____(____).select(fields)

# Print incorrect if prediction does not match label
for x in predictions.take(8):
    print()
    if x.label != int(x.____):
        print("INCORRECT ==> ")
    for y in fields:
        print(y,":", x[y])
Code bearbeiten und ausführen