← Quiz: Regularisation (Ridge and Lasso): all 10 questions
Quiz: Regularisation (Ridge and Lasso) · Question 7 of 10
What does this print? (code)
What does this print?
def soft_threshold(rho, alpha):
if rho > alpha:
return rho - alpha
if rho < -alpha:
return rho + alpha
return 0.0
print(soft_threshold(0.5, 0.2), soft_threshold(0.1, 0.2))
- A.0.3 0.0
- B.0.5 0.1
- C.0.7 0.0
- D.0.3 -0.1
Answer & explanation
Correct answer: 0.3 0.0
Values bigger than alpha shrink by alpha; values within ±alpha become exactly 0.
Can you get the rest right without peeking?
Take the timed Quiz: Regularisation (Ridge and Lasso) quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →