Generalized linear regression

Linear regression follows a Gaussian distribution, whereas, generalized linear models (GLMs) are specifications of linear models where the response variable Y follows some distribution from the exponential family of distributions.

Let's train the bike sharing dataset by splitting it into 80 % training and 20% testing, use GeneralizedLinearRegression with regression evaluator from Spark to build the model, and get evaluation metrics around the test data.

@transient lazy val logger = Logger.getLogger(getClass.getName) def genLinearRegressionWithVectorFormat(vectorAssembler:    VectorAssembler, vectorIndexer: VectorIndexer, dataFrame:    DataFrame) = {    val lr = new GeneralizedLinearRegression()  .setFeaturesCol("features") ...

Get Machine Learning with Spark - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.