1
$\begingroup$

Data nature:

I have features with 10 numeric type, and other 10 categorical, with a lot of values, at the end, using one-hot encoding I got a matrix of 600 columns. My problem is with accuracy which is 0.7, knowing that other peers got more that 0.9.

Problem:

Target data is binary, and is not evenly distributed at all. Trying blindly after pre-processing from sklearn.linear_model import LogisticRegression and sklearn.svm scored using roc_auc_score: .7 and .75.

Back to basics, I run this

train['cible'].value_counts() / train['cible'].count()

and got

1    0.970791
0    0.029209
Name: cible, dtype: float64

Quite interesting I think, but how can I improve accuracy. Any hints ?

Note: I will edit and add False Positive Rate and True Positive Rate as I lost output, after scaling, missing data imputation and retraining the model which takes couple of hours.

$\endgroup$

1 Answer 1

1
$\begingroup$

From scikitlearn LogisticRegression docs:

class_weight : dict or ‘balanced’, default: None

Weights associated with classes in the form {class_label: weight}. If not given, all classes are supposed to have weight one. The “balanced” mode uses the values of y to automatically adjust weights inversely proportional to class frequencies in the input data as n_samples / (n_classes * np.bincount(y)). Note that these weights will be multiplied with sample_weight (passed through the fit method) if sample_weight is specified. New in version 0.17: class_weight=’balanced’

So try to add class_weight='balanced'in your call to LogisticRegression()

Or maybe if this doesn't work, try to use as trainSet an evenly split dataset: where the number of samples of class 1 is equal to class 0.

$\endgroup$
2
  • $\begingroup$ I will give it a try and be back $\endgroup$
    – bacloud14
    Sep 27, 2018 at 16:48
  • $\begingroup$ From 0.75 to 0.8 ! No guess this helped in my case. $\endgroup$
    – bacloud14
    Sep 28, 2018 at 16:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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