🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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))
  1. A.0.3 0.0
  2. B.0.5 0.1
  3. C.0.7 0.0
  4. 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 →