Skip to content
DeepForgeby svx
All problems
EasyInformation Theoryinfo-226

VC Dimension Lookup

Problem

Return the VC dimension of a named hypothesis class, where d is the ambient dimension for classes that depend on it. Use these rules: interval -> 2, rectangle -> 4, halfspace -> d + 1, monotone_conjunction -> d, sinusoid -> -1 (infinite), and 0 for anything else.

Hint

A class with infinite VC dimension cannot be PAC learned without restrictions.

Test cases

case 1
in: ["interval",1]
expected: 2
case 2
in: ["rectangle",2]
expected: 4
case 3
in: ["halfspace",3]
expected: 4
case 4
in: ["sinusoid",1]
expected: -1
case 5
in: ["monotone_conjunction",5]
expected: 5
Starter codePython
def vc_dimension(name, d):
    # Your code here
    pass

5 test cases · run your code against them in the editor