Regarding application of logistic regression model

How can I apply logistic regression model on CrimeCast: Forecasting Crime Categories dataset of Kaggle? It’s a classification problem and all the data given in the columns are categorical data and I am not able to understand if there would be any help if OneHotEncoder or LabelEncoder is applied ! Please give me some insights on how I can proceed.

Hi @PG_Coursera

To do this task, first preprocess the categorical data using OneHotEncoder for nominal features to create binary columns, ensuring the model can handle them.

Then, split the dataset into training and testing sets, then train the logistic regression model on the processed training data.

Finally, evaluate the model’s performance.


Use OneHotEncoder where the categories do not have an inherent order. This converts each category into a separate binary column.

Use OrdinalEncoder for ordinal categorical features, where the categories have a meaningful order. It assigns a unique integer to each category while saving the order.

Keep in mind that, OrdinalEncoder is for converting features, while LabelEncoder is for converting target variable.

1 Like