0
$\begingroup$

So if my dataset looks like this:

  names life_style instrument  times
0   sid   creative      piano    1.5
1  aadi   artistic     guitar    1.4
2  aman  traveller       drum    1.1
3   sid   artistic     guitar    1.5
4  aadi   creative       drum    1.4

Now i want to deal with those Nominal categorical variables , Easy and go to approach is use Label encoding , But suppose if i am using sklearn label encoder then:

from sklearn.preprocessing import LabelEncoder
big_data = dataset_pd.apply(LabelEncoder().fit_transform)

which will output:

   names  life_style  instrument  times
0      2           1           2      2
1      0           0           1      1
2      1           2           0      0
3      2           0           1      2
4      0           1           0      1

Now it is converting each column but each column have same numeric values range from 0 to 5. The instrument variable is now similar to 'names' variable since both will have similar data points, which is certainly not a right approach. I have few questions :

  • How should i treat those values without loosing information ? better approach for this type of data points ?

  • I am thinking to use random forest for this type of data , Any suggestion on model also will be helpful for me.

  • If some variable are appearing only once in huge dataset should i remove those variables ?

Thank you in advance !

$\endgroup$
1
$\begingroup$
  1. Label encoder is better suited for output classes. You are looking to handle categorical variables. The term is "one hot encoding" which means creating a binary column for each unique value of categorical data. Check get_dummies function in Pandas
  2. It is hard to give any suggestion on model to use without knowing the objective, amount of data available, accuracy requirements. You are better off trying multiple models and checking test set errors to see which one works better.
  3. Variables with high degree of missing values or low fill rate can be removed from the dataset.
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.