Code Monkey home page Code Monkey logo

smote's Introduction

SMOTE

This class is the implementation of SMOTE technique of oversampling the data points in the imbalanced dataset.

๐Ÿ—ƒ๏ธ Which files?

In this repository, 2 files are there.

  1. .ipynb which is the step by step explanation of my approach
  2. .py which is the standalone SMOTE class for direct use.

๐Ÿค” How to import?

This is not the library but instead a direct implementation. So where erver you want to use the SMOTE class, you can simply copy the file there and then follow the standard import syntax.

Here I have implemented in the simplest way possible and is dependent upon only numpy and sklearn's linear regression.

โ„น๏ธ About

After you detect that you have got the problem of imbalanced instances per classes, you can simply use this class with ease.

After initializing, SMOTE class's object also has __repr__ which will display useful information.

๐Ÿค“ Parameters

While initializing:

X: DF / ndarray / list
    It must be 2D and numerical in nature.

y: Series / array / list
    It must be 1D and should have categories in it.

oversampling_size: float (between 0 to 1)
    It ensures that how much percentage of highset frequencied class
    you want to generate new samples for. 1 means 100% which means
    total frequences of all class will be same.

While Resampling:

k: int
    This defines how many neighbours to choose while generating a new
    data point. Default is 5.

๐Ÿ‘จโ€๐Ÿ’ป How To

# Seperate the Features X and Labels Y
# X should be numerical and 2D.
X = df[["feature1", "feature2"]]
y = df["target"]

synthesizer = SMOTE(oversampling_size=0.5) # means 50% samples generated.
synthesizer.resample(k=3)

# โ†“ this will return a dict with new data points
new_data = synthesizer.coords_by_class

Thanks!
Aayush โˆž Shah

smote's People

Contributors

aayushsameershah avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.