[Tutor] Explanation of smote and upsampling

Alan Gauld alan.gauld at yahoo.co.uk
Mon Nov 29 09:03:43 EST 2021


On 28/11/2021 23:03, Tariq Khasiri wrote:
> ‘’’
> 
> oversample = SMOTE()X, y =
> oversample.fit_resample(c_data[c_data.columns[1:]],
> c_data[c_data.columns[0]])usampled_df = X.assign(Churn = y)
> 
> 
> ‘’’
> 
> 
> Does this portion of code mean that I am upsampling column 0 and
> column 1 of my data frame ( c_data ) ? Please kindly advise. Not
> understanding this part of code —————->  c_data[c_data.columns[1:]


It helps if you tell us what libraries you are using.
This list is really for questions about the core language
and standard library. Anything extra needs some explanation.

Reformatting your code as I think it should be...

oversample = SMOTE()
X, y = oversample.fit_resample(
                      c_data[c_data.columns[1:]],
                      c_data[c_data.columns[0]]
                      )
usampled_df = X.assign(Churn = y)

As to the part you don't understand, that will largely depend on the
definition of c_data, which I assume is an instance of a class
in your library? But without knowing the library we can only
guess at what it does.

HTH
-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list