Imbalanced-Learn Random Over Sampler Removing Columns











up vote
-1
down vote

favorite












I'm training a multi label classifier to predict 'codes' for specific comments. My training set has a column with text and another with a list of codes (1 to 3) which I am trying to predict.



When I run:



from sklearn.preprocessing import MultiLabelBinarizer
from imblearn.over_sampling import RandomOverSampler

multilabel_binarizer = MultiLabelBinarizer()
multilabel_binarizer.fit(df.Code)

Y = multilabel_binarizer.transform(df.Code)

ros = RandomOverSampler(random_state=42)
X_resampled, Y_resampled = ros.fit_sample(X, Y)


Y has a shape of (12000, 168) but,
Y_resampled has a shape of (150000,166). I've looked through the source code but I can't seem to figure out why columns are disappearing. If anyone has any suggestions, it would be helpful.



Thank you!










share|improve this question






















  • can you add some data to reproduce the problem ?
    – seralouk
    Nov 8 at 21:05












  • You say you have a list of codes in y, from 1 to 3, then why does Y has a shape of (12000, 168). Why are 168 columns in it? Why are you doing MultiLabelBinarizer on it? According to RandomOverSampler documentation, it supports only a 1-d y, so why are you supplying 2-d Y to it?
    – Vivek Kumar
    Nov 9 at 12:24










  • Sorry for the confusion, I wasn't very clear. There are 168 unique codes, but up to 3 exist for each row. Multi-label bianrizer was used to create a 'dummy-variable-esque" matrix of what codes were present in each row. So, y is really a n by 168 matrix, each row containing up to three 1's and 165 0's.
    – gthom
    Nov 14 at 18:47

















up vote
-1
down vote

favorite












I'm training a multi label classifier to predict 'codes' for specific comments. My training set has a column with text and another with a list of codes (1 to 3) which I am trying to predict.



When I run:



from sklearn.preprocessing import MultiLabelBinarizer
from imblearn.over_sampling import RandomOverSampler

multilabel_binarizer = MultiLabelBinarizer()
multilabel_binarizer.fit(df.Code)

Y = multilabel_binarizer.transform(df.Code)

ros = RandomOverSampler(random_state=42)
X_resampled, Y_resampled = ros.fit_sample(X, Y)


Y has a shape of (12000, 168) but,
Y_resampled has a shape of (150000,166). I've looked through the source code but I can't seem to figure out why columns are disappearing. If anyone has any suggestions, it would be helpful.



Thank you!










share|improve this question






















  • can you add some data to reproduce the problem ?
    – seralouk
    Nov 8 at 21:05












  • You say you have a list of codes in y, from 1 to 3, then why does Y has a shape of (12000, 168). Why are 168 columns in it? Why are you doing MultiLabelBinarizer on it? According to RandomOverSampler documentation, it supports only a 1-d y, so why are you supplying 2-d Y to it?
    – Vivek Kumar
    Nov 9 at 12:24










  • Sorry for the confusion, I wasn't very clear. There are 168 unique codes, but up to 3 exist for each row. Multi-label bianrizer was used to create a 'dummy-variable-esque" matrix of what codes were present in each row. So, y is really a n by 168 matrix, each row containing up to three 1's and 165 0's.
    – gthom
    Nov 14 at 18:47















up vote
-1
down vote

favorite









up vote
-1
down vote

favorite











I'm training a multi label classifier to predict 'codes' for specific comments. My training set has a column with text and another with a list of codes (1 to 3) which I am trying to predict.



When I run:



from sklearn.preprocessing import MultiLabelBinarizer
from imblearn.over_sampling import RandomOverSampler

multilabel_binarizer = MultiLabelBinarizer()
multilabel_binarizer.fit(df.Code)

Y = multilabel_binarizer.transform(df.Code)

ros = RandomOverSampler(random_state=42)
X_resampled, Y_resampled = ros.fit_sample(X, Y)


Y has a shape of (12000, 168) but,
Y_resampled has a shape of (150000,166). I've looked through the source code but I can't seem to figure out why columns are disappearing. If anyone has any suggestions, it would be helpful.



Thank you!










share|improve this question













I'm training a multi label classifier to predict 'codes' for specific comments. My training set has a column with text and another with a list of codes (1 to 3) which I am trying to predict.



When I run:



from sklearn.preprocessing import MultiLabelBinarizer
from imblearn.over_sampling import RandomOverSampler

multilabel_binarizer = MultiLabelBinarizer()
multilabel_binarizer.fit(df.Code)

Y = multilabel_binarizer.transform(df.Code)

ros = RandomOverSampler(random_state=42)
X_resampled, Y_resampled = ros.fit_sample(X, Y)


Y has a shape of (12000, 168) but,
Y_resampled has a shape of (150000,166). I've looked through the source code but I can't seem to figure out why columns are disappearing. If anyone has any suggestions, it would be helpful.



Thank you!







python scikit-learn classification text-classification oversampling






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 8 at 16:57









gthom

1




1












  • can you add some data to reproduce the problem ?
    – seralouk
    Nov 8 at 21:05












  • You say you have a list of codes in y, from 1 to 3, then why does Y has a shape of (12000, 168). Why are 168 columns in it? Why are you doing MultiLabelBinarizer on it? According to RandomOverSampler documentation, it supports only a 1-d y, so why are you supplying 2-d Y to it?
    – Vivek Kumar
    Nov 9 at 12:24










  • Sorry for the confusion, I wasn't very clear. There are 168 unique codes, but up to 3 exist for each row. Multi-label bianrizer was used to create a 'dummy-variable-esque" matrix of what codes were present in each row. So, y is really a n by 168 matrix, each row containing up to three 1's and 165 0's.
    – gthom
    Nov 14 at 18:47




















  • can you add some data to reproduce the problem ?
    – seralouk
    Nov 8 at 21:05












  • You say you have a list of codes in y, from 1 to 3, then why does Y has a shape of (12000, 168). Why are 168 columns in it? Why are you doing MultiLabelBinarizer on it? According to RandomOverSampler documentation, it supports only a 1-d y, so why are you supplying 2-d Y to it?
    – Vivek Kumar
    Nov 9 at 12:24










  • Sorry for the confusion, I wasn't very clear. There are 168 unique codes, but up to 3 exist for each row. Multi-label bianrizer was used to create a 'dummy-variable-esque" matrix of what codes were present in each row. So, y is really a n by 168 matrix, each row containing up to three 1's and 165 0's.
    – gthom
    Nov 14 at 18:47


















can you add some data to reproduce the problem ?
– seralouk
Nov 8 at 21:05






can you add some data to reproduce the problem ?
– seralouk
Nov 8 at 21:05














You say you have a list of codes in y, from 1 to 3, then why does Y has a shape of (12000, 168). Why are 168 columns in it? Why are you doing MultiLabelBinarizer on it? According to RandomOverSampler documentation, it supports only a 1-d y, so why are you supplying 2-d Y to it?
– Vivek Kumar
Nov 9 at 12:24




You say you have a list of codes in y, from 1 to 3, then why does Y has a shape of (12000, 168). Why are 168 columns in it? Why are you doing MultiLabelBinarizer on it? According to RandomOverSampler documentation, it supports only a 1-d y, so why are you supplying 2-d Y to it?
– Vivek Kumar
Nov 9 at 12:24












Sorry for the confusion, I wasn't very clear. There are 168 unique codes, but up to 3 exist for each row. Multi-label bianrizer was used to create a 'dummy-variable-esque" matrix of what codes were present in each row. So, y is really a n by 168 matrix, each row containing up to three 1's and 165 0's.
– gthom
Nov 14 at 18:47






Sorry for the confusion, I wasn't very clear. There are 168 unique codes, but up to 3 exist for each row. Multi-label bianrizer was used to create a 'dummy-variable-esque" matrix of what codes were present in each row. So, y is really a n by 168 matrix, each row containing up to three 1's and 165 0's.
– gthom
Nov 14 at 18:47



















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53212597%2fimbalanced-learn-random-over-sampler-removing-columns%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53212597%2fimbalanced-learn-random-over-sampler-removing-columns%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Schultheiß

Verwaltungsgliederung Dänemarks

Liste der Kulturdenkmale in Wilsdruff