Should I build a different model for each subset I have a dataset which has categorical variable class. I am trying to solve a regression problem

I am not understanding whether I should build a model on entire dataset and consider variable class as one of the input variable or for each class should I build a different model altogether.

What are general rules which can help me deciding between two approaches.

This is a sample of how my data looks like

+------------+----+-----+-----------------+
|   Class    | X1 | X2  |     Speed       |
+------------+----+-----+-----------------+
| Class1     | 12 | 123 |              10 |
| Class2     | 14 | 120 |              32 |
| Class3     | 15 |  34 |              12 |
|   .        |  . |   . |               . |
|   .        |  . |   . |               . |
|   .        |    |     |                 |
|  Class 300 | 23 |  13 |              45 |
+------------+----+-----+-----------------+


Class is the input categorical variable and I have around 300 classes. The output variable is Speed. I am trying to predict the speed with variables Class, X1, X2.

Should I build a model for each Class separately. So when I know input type is Class1 I will select model built for Class1. When input type is Class2 I will use model built for Class2 and so on. Also the values in Class variable can repeat meaning Class1 can come 4 times, Class2 can come 8 times etc

Other way I was thinking is to include Class itself as a variable and just build one model.

I don't know which would be the correct way for it
Build one model including the class variable as a categorical feature. 

Since it is a high cardinality feature, there are different techniques that you can use:


One hot encoding (would create around 300 variables based on different classes)
Label encoding (would be a single variable but will assign weights to different classes - not ideal)
Hashing trick - use a hashing function to reduce the number of features
Embeddings
Cluster the different classes together