3
$\begingroup$

I would greatly appreciate if you could let me know how to use SMOTENC. I wrote:

num_indices1 = list(X.iloc[:,np.r_[0:94,95,97,100:123]].columns.values)
cat_indices1 = list(X.iloc[:,np.r_[94,96,98,99,123:160]].columns.values)
print(len(num_indices1))
print(len(cat_indices1))

pipeline=Pipeline(steps= [
    # Categorical features
    ('feature_processing', FeatureUnion(transformer_list = [
            ('categorical', MultiColumn(cat_indices1)),

            #numeric
            ('numeric', Pipeline(steps = [
                ('select', MultiColumn(num_indices1)),
                ('scale', StandardScaler())
                        ]))
        ])),
    ('clf', rg)
    ]
)

Therefore, as it is indicated I have 5 categorical features. Really, indices 123 to 160 are related to one categorical feature with 37 possible values which is converted into 37 columns using get_dummies.

I think SMOTENC should be inserted before the classifier ('clf', reg) but I don't know how to define "categorical_features" in SMOTENC. Besides, could you please let me know where to use imblearn.pipeline?

Thanks in advance.

$\endgroup$
  • $\begingroup$ Hi, unfortunately I'm not familiar with the concept. $\endgroup$ – Media Jan 20 '19 at 12:42
  • $\begingroup$ Kari nakardam :) $\endgroup$ – Media Jan 21 '19 at 11:33
  • $\begingroup$ @Media Hi, I installed Pycharm+Anaconda on a different system. However, I don't know how to resolve this error: no python interpreter configured for the project Thanks a lot. $\endgroup$ – ebrahimi Jan 30 '19 at 13:50
  • $\begingroup$ The reason is that anaconda uses its own distribution of python. There are numerous solutions, you can a instal a separate independent python and specify its path in the pycharm. Or you can simply type spyder in your cmd and use your current anaconda in spyder IDE. $\endgroup$ – Media Jan 30 '19 at 16:52
  • $\begingroup$ @Media Hi. Nowruz Mobarak. $\endgroup$ – ebrahimi Mar 30 '19 at 9:21
0
$\begingroup$

As it follows, two pipelines should be used:

num_indices1 = list(X.iloc[:,np.r_[0:94,95,97,100:120,121:123]].columns.values)
cat_indices1 = list(X.iloc[:,np.r_[94,96,98,99,120]].columns.values)
print(len(num_indices1))
print(len(cat_indices1))
cat_indices = [94, 96, 98, 99, 120]

from imblearn.pipeline import make_pipeline

pipeline=Pipeline(steps= [
    # Categorical features
    ('feature_processing', FeatureUnion(transformer_list = [
            ('categorical', MultiColumn(cat_indices1)),

            #numeric
            ('numeric', Pipeline(steps = [
                ('select', MultiColumn(num_indices1)),
                ('scale', StandardScaler())
                        ]))
        ])),
    ('clf', rg)
    ]
)
pipeline_with_resampling = make_pipeline(SMOTENC(categorical_features=cat_indices), pipeline)
| improve this answer | |
$\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.