0
votes

I am trying to assign my own weights for initialization for SVM in spark. But I get wrong prediction values after training the model. If I use default ones i.e don't supply an initial weight vector I get a good prediction model.

I checked the code at github but couldn't figure out how the initialization is done in case we don't pass anything. https://github.com/apache/spark/blob/master/mllib/src/main/scala/org/apache/spark/mllib/classification/SVM.scala.

Any suggestions?

Edit: I have 0 experience with scala

1

1 Answers

2
votes

SVMWithSGD inherits its run method from a GeneralizedLinearAlgorithm. If weights vector is not provided it is simply initialized using vector of zeros:

val initialWeights = {
  if (numOfLinearPredictor == 1) {
    Vectors.zeros(numFeatures)
  } else if (addIntercept) {
    Vectors.zeros((numFeatures + 1) * numOfLinearPredictor)
  } else {
    Vectors.zeros(numFeatures * numOfLinearPredictor)
  }
}