Skip to content

Instantly share code, notes, and snippets.

@SuzieJi
Last active August 22, 2020 02:19
lr = LinearRegression(labelCol='Yearly_Amount_Spent')
lr_model = lr.fit(train_data)
print("Coefficients: " + str(lr_model.coefficients))
print("Intercept: " + str(lr_model.intercept))
lr_model.write().overwrite().save("models/Ecommerce_Customer_001")
trainingSummary = lr_model.summary
print("numIterations: %d" % trainingSummary.totalIterations)
print("objectiveHistory: %s" % str(trainingSummary.objectiveHistory))
trainingSummary.residuals.show()
print("RMSE: %f" % trainingSummary.rootMeanSquaredError)
print("r2: %f" % trainingSummary.r2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment