# Categorical feature as output and perform a classification

I have a database in which the output feature Y is categorical, for example (oversimplification)

A          B        C        Y
1.0        0.2      5.1      Car
3.0        1.1      0.1      Car
7.6        6.9      2.7      Bike
2.5        3.8      0.3      Train
6.1        9.5      8.4      Car
8.4        0.7      5.6      Train


and so on.......

I would like to run a classification algorithm like kNN, Logistic Regression or Random Forest using as the output feature the column Y, i.e., to predict which transport was used.

How could I implement that in python since the output is not numerical?

from sklearn.preprocessing import LabelEncoder

So what you are looking for is scikit-learn's LabelEncoder which will transform categorical values (e.g. car, bike, motorbike) to numerical values (1, 2, 3).
In case you have also categorical variables as features (X-Values) in your data set, I recommend using OneHotEncoder or pandas implementation of get_dummies() when dealing with categories. LabelEncoder would imply an order of the features (e.g. responds to a survey "Would you buy Product A" - (1) Never, (2) Not likely, (3) Don't know, (4) Likely, (5) Yes)