package to do SMOTE in R
Asked Answered
D

4

7

I am trying to do SMOTE in R for imbalanced datasets. I tried installing "DMwR" package for this, but it seems this package has been removed from the cran repository. I am getting the error:" package ‘DMwR’ is not available (for R version 4.0.2) "

Can anyone please help me with this? Or suggest any other package to use SMOTE in R?

TIA!

Dichromic answered 14/4, 2021 at 5:1 Comment(0)
L
6

You are right. The Error message means that the package is not supported by the newest version of R (4.x.x).

As far as I know the package you are looking for is called "smotefamily" now.

install.packages("smotefamily")

should give you what you need

Landgrabber answered 14/4, 2021 at 5:18 Comment(0)
D
6

smotefamily is an option but the syntax is a bit different than the older syntax used in DMwR. In fact it does not support the classic formula that is used in caret, e.g. target ~ . (see documentation SMOTE(X, target, K = 5, dup_size = 0) https://cran.r-project.org/web/packages/smotefamily/smotefamily.pdf).

Instead the performanceEstimation package has exactly the same formulation of the SMOTE implemented in DMwR:

smote(form, data, perc.over = 2, k = 5, perc.under = 2)

see documentation https://rdrr.io/cran/performanceEstimation/man/smote.html

Doggish answered 22/7, 2021 at 23:7 Comment(0)
U
1

Big loss with caret for subsambling techniques.

You can find available versions from the archives, download the desired archive and install it as follows:

install.packages("/path/to/archive/DMwR_0.4.1.tar.gz", repos=NULL, type="source")

Personally I can't find an available version for R 4.0.5 (2021-03-31)... I will have to install an older version of R.

Undergraduate answered 22/4, 2021 at 9:7 Comment(0)
M
0
smote function from mlr package is another good option.

https://www.rdocumentation.org/packages/mlr/versions/2.19.1/topics/smote

Matildematin answered 15/4 at 12:20 Comment(1)
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Urogenital

© 2022 - 2024 — McMap. All rights reserved.