Database Reference
In-Depth Information
Metrics for varying levels of L1 regularization
Using L1 regularization can encourage sparse weight vectors. Does this hold true in this
case? We can find out by examining the number of entries in the weight vector that are
zero, with increasing levels of regularization:
model_l1 = LinearRegressionWithSGD.train(train_data, 10,
0.1, regParam=1.0, regType='l1', intercept=False)
model_l1_10 = LinearRegressionWithSGD.train(train_data, 10,
0.1, regParam=10.0, regType='l1', intercept=False)
model_l1_100 = LinearRegressionWithSGD.train(train_data,
10, 0.1, regParam=100.0, regType='l1', intercept=False)
print "L1 (1.0) number of zero weights: " +
str(sum(model_l1.weights.array == 0))
print "L1 (10.0) number of zeros weights: " +
str(sum(model_l1_10.weights.array == 0))
Search WWH ::




Custom Search