Handle Categorical Variables in Machine Learning in Python I have $4$ variables in the data-set, each has more than $50$ levels in them. I want to include all these variables in my predictive model. How should I handle these categorical variables? 
If I do label encoding, $0\dots n-1$ numbers will be assigned to the levels in the variable, but won't this going to make the levels ordinal? I want to try models like K-NN, Random Forest, Deep Learning, SVM.
I am using Python for model building. 
 A: Rather than assigning the numbers $1...k$ for $k$ classes, you can encode a nominal factor using one-hot encoding. This will create a vector for each class and assign a $1$ to the element(s) that correspond(s) to that class, and a $0$ elsewhere.
Take for example this image from a related question on SO:

You could also observe that you don't actually need 5 vectors to represent 5 classes and use sparse encoding, setting the last vector to all $0$.
I'm not familiar with Python, but most statistical software has built-in functions for turning your categorical vector into $k-1$ vectors (maybe search for "Python design matrix").
A: The statistical package you are using may be able to handle categoricals natively. Check that first.
If you are using a package that does not support categoricals natively, 1-hot encode may or may not work well with the algorithm (oversampling, constant columns, low information). But 1-hot encoding is easy so it is worth trying.
You can also try frequency/mean or mixed effect encoding.
For frequency/mean see Elements of Statistical Learning section 9.2.4. It is described in terms of trees however the encoding scheme can be used in other algorithms. In a binary classification, replace each category with its frequency of the event. In a regression, replace the category with the mean of the target. The categorical feature stays at 1 feature, it is now numeric and conveys information.
A similar concept with mixed effect encoding. The fixed effects are the non-categorical predictors. The random effect is the categorical. Replace each category with the fitted random effect.
A downside of these encoding schemes is the loss of the information of categories. If one of the categorical features is US States, with frequency/mean or mixed effect encoding, the model will not convey information about an individual US State. But the effect/importance of the categorical feature can be found. To the problem you are solving, this may help or hinder.
If your categoricals have a hierarchal structure, you may be able to group manually using subject matter expertise (e.g. product groups) or on statistical methods. Hierarchal clustering encoding may work for you. Here is a paper that describes another hierarchical clustering technique. I have not used the technique in this paper so I do not have an opinion but it is bookmarked in case I hit this situation.
These are old techniques that were sometimes used when computers were not as powerful (CPUs and memory). 
With the goals of your model and understanding the features one of these schemes (including 1-hot encoding) may work out for you.
