df = rf_model.transform(df).select("id", "probability", "prediction") df = df.withColumn("prediction", df["prediction"