If you really wanted to stretch a point regarding the "grammaticality" of this particular (far from unknown) usage, you could say it's a perfectly valid imperative - reduced from some "underlying" full form such as...
You [the class] [please] begin [to pay attention!]
...or the "vocative" (invocation / appeal; I don't know the specific grammatical term)...
[Let the] class begin
But honestly, in contexts like this no-one really cares about "grammar". The teacher is simply trying to get the class to pay attention because he's about to start the lesson. But I'd say that semantically the initial word Class is definitely a form of address (to get their collective attention).
It would be just a matter of opinion whether the second word might be interpreted as a cut down version of something more complex, such as [pay attention as I] begin [the formal part of this teaching period].
In my recollection (going back half a century now! :) it was common for our teachers to say things like Simmer down, now! But perhaps modern American teachers favour Listen up, now! Whatever - the idea of there being a "standard, syntactically valid" term for the context is effectively meaningless.