- We can also change the default intercept behavior using the constructor to create a new regression model and then using setIntercept(true) accordingly:
The sample code is as follows:
val myModel = new LinearRegressionWithSGD().setIntercept(true)
- If the weight for the model is computed as NaN, you must change the model parameters (SGD steps or number of iterations) until you get convergence. An example is model weights that are not computed correctly (there is a convergence problem with SGD in general) due to poor parameter selection. The first move should be to use a more fine-grain step parameter for SGD:
(Model Weights:,[NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN])