Imbalanced datasets help

this is my code with which i tried to attack my imbalanced dataset from here https://www.kaggle.com/mlg-ulb/creditcardfraud.

Now i have 2 questions. 1) When i try to split my data into train/test data and try to run the table() function, i always get the error : Error in table(train) : attempt to make a table with >= 2^31 elements How do i fix that and the other errors? 2) Now i try to compare accuary between those techniques. I would love to use the ConfusionMatrix on it? How do i implement it into my code?

Thats my code:

library(ROSE)
library(rpart)
library(rpart.plot)
library(ggplot2)
library(UBL)
library(caret)
library(SMOTE)
library(tidyverse)
library(DMwR)
install.packages("partykit")
library(partykit)

setwd("C:\\Users\\loren\\Dropbox\\Uni\\Präsentation\\Datensätze")
daten <- read.csv("creditcard.csv")
head(data1)
prop.table(table(daten$Class))
table(daten$Class)

index1 <- sample(2, nrow(daten), replace = TRUE, prob = c(0.8, 0.2))
train <- daten[index1==1,]
test <- daten[index1==2,]
table(train)

index <- createDataPartition(daten$Class, p = 0.8, list = FALSE)
train_data <- daten[index, ]
test_data  <- daten[-index, ]

table(train_data)
table(test_data)

# Down-Sample
down_train <- downSample(x = train_data[, -ncol(train_data)],
                     y = train_data$Class)
table(down_train$Class)
fit_down <- rpart(Class~., data = down_train)
pred_down <- predict(fit_down, newdata = test)

# Up-Sample
up_train <- upSample(x = uniaug_train[, -ncol(uniaug_train)],
                 y = uniaug_train$)
table(up_train$Class)
fit_up <- rpart(Class~., data = up_train)
pred_up <- predict(fit_up, newdata = test)

# SMOTE
library(DMwR)
smote_train <- SMOTE(Class~., data = train_data)
table(smote_train$Class)
fit_smote <- rpart(Class~., data = smote_train)
pred_smote <- predict(fit_smote, newdata = test)

# ROSE
rose_train <- ROSE(Class~., data = train_data)$data
table(rose_train$Class)
fit_rose <- rpart(Class~., data = rose_train)
pred_rose <- predict(fit_rose, newdata = test)


# Confusion-Matrix

Thx in advance

Hi @Mingabua: It may be that someone might be able to diagnose the issue from looking at your code, but if you could a sample of your data, that help folks be able to help you more easily. Could you run dput(head(daten, 50)) and paste the output here, like this?

```
<--- paste output here
```
1 Like

First of all, thanks for your answer. I got rid of the "to many elements" error by adding $Class to table(train_data$Class)

Thats the output. Now that i got the first part fixed, my over/under/Smote wont work.
These are the errors.

  1. In downSample(x = train_data[, -ncol(train_data)], y = train_data$Class) : Down-sampling requires a factor variable as the response. The original data was returned. For Downsampling

  2. Error: unexpected ')' in: "up_train <- upSample(x = uniaug_train[, -ncol(uniaug_train)], y = uniaug_train$)" For Upsampling

  3. Error in T[i, ] : subscript out of bounds In addition: There were 50 or more warnings (use warnings() to see the first 50) Not sure if this is an error

It would be helpful for you to post the modified code you used, too, otherwise it's hard to know what triggered the error.

Sure, sorry.

setwd("C:\\Users\\loren\\Dropbox\\Uni\\Präsentation\\Datensätze")
daten <- read.csv("creditcard.csv")
head(daten)
prop.table(table(daten$Class))
table(daten$Class)

index <- createDataPartition(daten$Class, p = 0.8, list = FALSE)
train_data <- daten[index, ]
test_data  <- daten[-index, ]

table(train_data$Class)
prop.table(table(train_data$Class))
table(test_data$Class)
prop.table(table(test_data$Class))

# Down-Sample
down_train <- downSample(x = train_data[, -ncol(train_data)],
                         y = train_data$Class)
table(down_train$Class)
fit_down <- rpart(Class~., data = down_train)
pred_down <- predict(fit_down, newdata = test_data)

# Up-Sample
up_train <- upSample(x = train_data[, -ncol(train_data)],
                     y = train_data$Class)
table(up_train$Class)
fit_up <- rpart(Class~., data = up_train)
pred_up <- predict(fit_up, newdata = test_data)

# SMOTE
library(DMwR)
smote_train <- SMOTE(Class~., data = train_data)
table(smote_train$Class)
fit_smote <- rpart(Class~., data = smote_train)
pred_smote <- predict(fit_smote, newdata = test_data)

# ROSE
rose_train <- ROSE(Class~., data = train_data)$data
table(rose_train$Class)
fit_rose <- rpart(Class~., data = rose_train)
pred_rose <- predict(fit_rose, newdata = test_data)

Hi @Mingabua: I'm finding it difficult to follow since your code is changing and doesn't match the errors you asked about. I would suggest trying to deal with each error you encounter, one at a time, so maybe next it would be helpful to first post the data and code needed to create train_data, and then post just the 'Down-Sample' code. If you do this as a reprex, the errors will show up for everyone to see. Does this make sense?


setwd("C:\\Users\\loren\\Dropbox\\Uni\\Präsentation\\Datensätze")
daten <- read.csv("creditcard.csv")
head(daten)
prop.table(table(daten$Class))
table(daten$Class)

index <- createDataPartition(daten$Class, p = 0.8, list = FALSE)
train_data <- daten[index, ]
test_data  <- daten[-index, ]

table(train_data$Class)
prop.table(table(train_data$Class))
table(test_data$Class)
prop.table(table(test_data$Class))

down_train <- downSample(x = train_data[, -ncol(train_data)],
                         y = train_data$Class)

This is my code which i use to create train_data and test_data. I got rid of the first error. The problem now is, i cant run the downSample command on it. I always get this error.

"Warning message:
In downSample(x = train_data[, -ncol(train_data)], y = train_data$Class) :
Down-sampling requires a factor variable as the response. The original data was returned." How do i fix that?

Thanks, @Mingabua: Could you say what packages contain the functions prop.table(), createDataPartition, and downSample? That would help me selectively install what's needed since I have limited space on my machine.

prop.table should be a standard function. downSample is from ‚caret‘ and createDataPartition is from ,caret, aswell

Great -- thanks, @Mingabua. I'll see if I can reproduce the error from the data you posted.

OK, @Mingabua: Here's a self-contained reprex, which is what I would ask you do to, too, as folks try to help with these issues. I've separated data you supplied from the code, and I get an error on the first command:

load your data
daten <-
structure(list(Time = c(0, 0, 1, 1, 2, 2, 4, 7, 7, 9, 10, 10, 
10, 11, 12, 12, 12, 13, 14, 15, 16, 17, 18, 18, 22, 22, 23, 23, 
23, 23, 24, 25, 26, 26, 26, 26, 27, 27, 29, 29, 32, 32, 33, 33, 
34, 34, 34, 34, 35, 35), V1 = c(-1.359807134, 1.191857111, -1.358354062, 
-0.966271712, -1.158233093, -0.425965884, 1.229657635, -0.644269442, 
-0.894286082, -0.338261752, 1.449043781, 0.384978215, 1.249998742, 
1.069373588, -2.791854766, -0.752417043, 1.103215435, -0.436905071, 
-5.401257663, 1.492935977, 0.694884776, 0.96249607, 1.166616382, 
0.247491128, -1.946525131, -2.074294672, 1.17328461, 1.322707269, 
-0.41428881, 1.059387115, 1.23742903, 1.114008595, -0.529912284, 
-0.529912284, -0.535387763, -0.535387763, -0.246045949, -1.452187279, 
0.996369532, 1.110880342, 1.24905472, -2.008871795, -0.607877143, 
-0.935731509, -0.762255666, 1.138315566, -0.291540245, 0.201685891, 
1.386396974, -1.063235679), V2 = c(-0.072781173, 0.266150712, 
-1.340163075, -0.185226008, 0.877736755, 0.960523045, 0.141003507, 
1.417963545, 0.286157196, 1.119593376, -1.176338825, 0.616109459, 
-1.221636809, 0.287722129, -0.327770757, 0.345485415, -0.040296215, 
0.918966213, -5.450147834, -1.029345732, -1.361819103, 0.328461026, 
0.502120088, 0.277665627, -0.044900505, -0.121481799, 0.353497877, 
-0.174040833, 0.905437323, -0.175319187, 0.061042584, 0.08554609, 
0.873891581, 0.873891581, 0.865267808, 0.865267808, 0.473266903, 
1.765123739, -0.122588787, 0.168716771, -0.624727077, 2.198526503, 
1.031345078, 0.170415774, 0.127767752, 0.05695597, 0.445575314, 
0.497483215, -0.794209465, 1.418190626), V3 = c(2.536346738, 
0.166480113, 1.773209343, 1.79299334, 1.548717847, 1.141109342, 
0.045370774, 1.074380376, -0.113192213, 1.044366552, 0.913859833, 
-0.874299703, 0.383930151, 0.828612727, 1.641750161, 2.057322913, 
1.267332089, 0.924590774, 1.186304631, 0.454794734, 1.02922104, 
-0.171479054, -0.067300314, 1.185470842, -0.405570068, 1.32202063, 
0.283905065, 0.434555031, 1.727452944, 1.266129643, 0.38052588, 
0.493702487, 1.347247329, 1.347247329, 1.351076288, 1.351076288, 
1.695737554, 0.611668541, 0.546819473, 0.51714396, -0.710588904, 
0.14424174, 1.740449737, 2.746261269, 2.650056386, 0.649418965, 
1.249752116, 1.373912574, 0.778224191, 1.086672863), V4 = c(1.378155224, 
0.448154078, 0.379779593, -0.863291275, 0.403033934, -0.16825208, 
1.202612737, -0.492199018, -0.27152613, -0.222187277, -1.375666655, 
-0.094018626, -1.234898688, 2.71252043, 1.767472744, -1.468643298, 
1.28909147, -0.727219054, 1.7362388, -1.43802588, 0.834159299, 
2.109204068, 2.261569239, -0.09260255, -1.013057337, 0.410007514, 
1.133563318, 0.576037652, 1.473471267, 1.186109955, 0.761564111, 
1.335759985, 0.145456677, 0.145456677, 0.147575474, 0.147575474, 
0.262411488, 1.176824984, 0.706579541, 1.32540692, -0.991600361, 
1.159432262, 1.23210555, -1.077964912, -1.875662771, 0.873062041, 
-1.73573589, 0.571405318, -0.864708434, 1.2414396), V5 = c(-0.33832077, 
0.060017649, -0.503198133, -0.01030888, -0.407193377, 0.420986881, 
0.191880989, 0.948934095, 2.66959866, 0.499360806, -1.971383165, 
2.924584378, -1.485419474, -0.178398016, -0.136588446, -1.15839368, 
-0.735997164, 0.915678718, 3.049105878, -1.555434101, -1.191208794, 
1.129565571, 0.428804195, -1.314393979, 2.9419677, 0.295197546, 
-0.172577182, -0.836758046, 0.007442741, -0.786001753, -0.35977071, 
-0.300188551, 0.414208858, 0.414208858, 0.433680212, 0.433680212, 
-0.010866414, -0.445979892, 0.134559557, -0.191573354, 1.429973192, 
-0.815174288, 0.41859226, -0.305594036, -0.893356398, -0.468466331, 
0.085755559, -0.63065775, -1.06413228, 0.002306126), V6 = c(0.462387778, 
-0.082360809, 1.800499381, 1.247203168, 0.095921462, -0.029727552, 
0.272708123, 0.428118463, 3.721818061, -0.246761101, -0.629152139, 
3.317027168, -0.753230165, 0.33754373, 0.807596468, -0.077849829, 
0.288069163, -0.127867352, -1.763405574, -0.720961147, 1.309108819, 
1.696037686, 0.089473517, -0.150115998, 2.955053397, -0.95953723, 
-0.916053707, -0.831083411, -0.200330677, 0.578435276, -0.49408415, 
-0.010753783, 0.100223094, 0.100223094, 0.086982938, 0.086982938, 
-0.610835935, 0.246826452, 1.156995112, 0.019503723, 3.692977019, 
0.182288271, 0.119168119, 0.011577039, -0.268714889, -0.410194552, 
-0.121924299, -0.539659124, 0.351296174, 0.045901581), V7 = c(0.239598554, 
-0.078802983, 0.791460956, 0.23760894, 0.592940745, 0.476200949, 
-0.005159003, 1.120631358, 0.370145128, 0.651583206, -1.423235601, 
0.470454672, -0.689404975, -0.096716862, -0.42291139, -0.608581418, 
-0.586056786, 0.707641607, -1.559737699, -1.08066413, -0.878585911, 
0.107711607, 0.24114658, -0.94636495, -0.063063147, 0.543985491, 
0.369024845, -0.264904961, 0.740228319, -0.767084276, 0.006494218, 
-0.118760015, 0.711206083, 0.711206083, 0.693039311, 0.693039311, 
0.793936546, -0.257566156, -0.294561331, -0.031849108, -1.090208641, 
-0.617108302, 0.850892666, -0.296178451, -0.419863597, -0.013897554, 
0.407715857, -0.076270291, -1.191454583, 0.514120897), V8 = c(0.098697901, 
0.085101655, 0.247675787, 0.377435875, -0.270532677, 0.260314333, 
0.08121294, -3.807864239, 0.851084443, 0.069538587, 0.048455888, 
0.538247228, -0.227487228, 0.115981736, -1.907107476, 0.003603484, 
0.189379714, 0.087962355, 0.160841747, -0.053127118, 0.445290128, 
0.521502164, 0.138081705, -1.617935051, 0.855546309, -0.104626728, 
-0.327260242, -0.220981943, -0.0292474, 0.401046149, -0.13386238, 
0.188616696, 0.176065957, 0.176065957, 0.179742261, 0.179742261, 
-0.247252831, 1.092472497, 0.407429099, 0.11761992, 0.967290815, 
1.530816728, -0.176267419, 0.40277557, 0.146233407, -0.072439609, 
0.095309378, -0.91710575, 0.052685634, 0.241252403), V9 = c(0.36378697, 
-0.255425128, -1.514654323, -1.387024063, 0.817739308, -0.568671376, 
0.464959995, 0.615374731, -0.392047587, -0.736727316, -1.720408393, 
-0.558894612, -2.094010573, -0.221082566, 0.755712908, -0.436166984, 
0.782332892, -0.665271354, 1.23308974, -1.978681595, -0.446195832, 
-1.191311102, -0.989162395, 1.544071402, 0.0499669, 0.475664018, 
-0.246651028, -1.071424618, -0.593392019, 0.699499676, 0.438809737, 
0.205686849, -0.286716935, -0.286716935, -0.285641861, -0.285641861, 
0.138879114, -0.607524461, 0.337862664, 0.017664721, 0.850148519, 
-0.586832286, -0.243501348, -0.040471746, -0.86963529, 0.306787909, 
0.815902287, 0.270008406, -0.304404039, -0.154499951), V10 = c(0.090794172, 
-0.166974414, 0.207642865, -0.054951922, 0.753074432, -0.371407197, 
-0.099254321, 1.249376178, -0.410430433, -0.366845639, 1.626659058, 
0.309755394, 1.323729274, 0.460230444, 1.151086988, 0.747730827, 
-0.267975067, -0.737979824, 0.345172827, 1.638076037, 0.568520735, 
0.724396315, 0.922174967, -0.829880601, 0.573742508, 0.149450615, 
-0.046139302, 0.868558548, -0.346188231, -0.064737556, -0.207358046, 
0.082262259, -0.484687683, -0.484687683, -0.482474471, -0.482474471, 
-0.401007068, 0.047155553, -0.408150493, 0.044864791, -0.307081112, 
0.129875751, 0.14845549, -0.852045976, -0.038651669, -0.269952637, 
-1.491188012, -0.480280682, 0.576516809, 0.280672622), V11 = c(-0.551599533, 
1.612726661, 0.624501459, -0.226487264, -0.822842878, 1.34126198, 
-1.416907243, -0.619467796, -0.705116587, 1.017614468, 1.19964395, 
-0.259115564, 0.227666231, -0.773656931, 0.844555471, -0.793980603, 
-0.45031128, 0.324097813, 0.917229868, 1.077542412, 1.019150613, 
1.690329921, 0.744785789, -0.583199527, -0.081256515, -0.856566364, 
-0.143418527, -0.64150629, -0.012142188, 1.048292488, -0.929182115, 
1.133555671, 0.87248959, 0.87248959, 0.87179958, 0.87179958, 
-0.812050382, 0.783726853, 0.682646124, 1.345074799, -0.456245308, 
0.658479448, -0.387003094, 1.552109306, -0.686124387, -0.002601848, 
-0.84619138, -0.51253274, -1.631111762, -0.531948028), V12 = c(-0.617800856, 
1.065235311, 0.066083685, 0.178228226, 0.53819555, 0.359893837, 
-0.153825826, 0.291474353, -0.110452262, 0.83638957, -0.671439778, 
-0.326143234, -0.242681999, 0.323387245, 0.792943952, -0.770406729, 
0.936707715, 0.277192107, 0.970116716, -0.632046515, 1.298328701, 
0.406773576, -0.53137725, 0.524933232, -0.215745003, -0.180523156, 
0.979350376, -0.111315775, 0.786796316, 1.005618365, 0.527106061, 
0.626699002, 0.85163586, 0.85163586, 0.853447435, 0.853447435, 
-0.183524462, 1.096385674, 1.253719685, 1.286339621, 0.22998135, 
1.265049218, 0.398299277, 0.95356103, -0.502910879, 1.124304216, 
0.05653255, 0.680906259, 0.042559512, 0.589857529), V13 = c(-0.991389847, 
0.489095016, 0.717292731, 0.50775687, 1.345851593, -0.358090653, 
-0.751062716, 1.757964214, -0.286253632, 1.006843514, -0.513947153, 
-0.090046723, 1.205416808, -0.011075887, 0.370448093, 1.047626997, 
0.708380406, 0.252624256, -0.266567765, -0.416957167, 0.420480265, 
-0.936421296, -2.10534645, -0.453375297, 0.044160628, -0.65523293, 
1.492285435, 0.36148541, 0.635953883, -0.542001579, 0.348675901, 
-1.492780392, -0.571745303, -0.571745303, -0.571821891, -0.571821891, 
-0.630112887, -0.268094206, 0.391917044, -0.252267066, -0.0169131, 
-0.206518166, 0.481916748, 0.415429902, 1.380826322, 0.744206684, 
-0.05895353, 0.089923037, 2.047898316, 0.555086956), V14 = c(-0.311169354, 
-0.143772296, -0.165945923, -0.287923745, -1.119669835, -0.1371337, 
0.167371963, -1.32386522, 0.07435536, -0.443522817, -0.095045045, 
0.362832369, -0.317630527, -0.178485175, -0.734975106, -1.066603681, 
-0.468647288, -0.29189646, -0.479129929, 0.052010515, -0.372650997, 
0.983739419, 1.126870105, 0.081393088, 0.033897757, -0.279796856, 
0.101417526, 0.171945122, -0.086324472, -0.039914502, -0.152535139, 
0.520787894, 0.100974273, 0.100974273, 0.102252103, 0.102252103, 
-0.286217451, 0.76864804, -0.037510858, 0.274457682, -0.220846086, 
1.013603212, -0.365439093, -0.233899925, -1.039124606, -0.188353421, 
0.151922602, -0.157405057, -0.739338429, -0.116357329), V15 = c(1.468176972, 
0.635558093, 2.345864949, -0.631418118, 0.17512113, 0.517616807, 
0.050143594, 0.686132504, -0.32878305, 0.150219101, 0.230930409, 
0.928903661, 0.72567499, -0.655564278, 0.40679571, 1.106953457, 
0.354574063, -0.184520169, -0.526608503, -0.042978923, -0.807979513, 
0.710910766, 0.003075323, 1.555204196, 1.190717675, -0.211667955, 
0.761477545, 0.782166532, 0.076803687, -0.218683248, -0.21838563, 
-0.674592597, -1.519771833, -1.519771833, -1.519991203, -1.519991203, 
-0.337046324, -0.524367354, 0.795301519, -0.810394372, 0.362417699, 
-0.54941351, 0.235544572, 0.452335832, 0.652842089, -0.075661963, 
1.982594882, -0.588819332, 1.456222044, 0.165886171), V16 = c(-0.470400525, 
0.463917041, -2.890083194, -1.059647245, -0.451449183, 0.401725896, 
-0.443586798, -0.076126999, -0.210077268, 0.739452777, 0.031967467, 
-0.129486811, -0.815612186, -0.199925171, -0.303057624, 1.660113557, 
-0.246634656, 1.143173707, 0.472004112, -0.166432496, -2.044557483, 
-0.602231772, 0.424424506, -1.396894893, 0.578843475, -0.33332061, 
-0.014584082, -1.35587073, -1.405919334, 0.004475682, -0.191551818, 
-0.529108242, -0.284375978, -0.284375978, -0.285912497, -0.285912497, 
-0.428105474, -0.808816147, -1.668210591, -0.587005063, 0.315222304, 
-0.708034201, -1.34781146, 0.844368277, 1.898747563, -0.709192272, 
-0.443295054, -0.477908446, -0.272049583, -1.237210027), V17 = c(0.207971242, 
-0.114804663, 1.109969379, -0.684092786, -0.237033239, -0.058132823, 
0.002820512, -1.222127345, -0.499767969, -0.540979922, 0.253414716, 
-0.809978926, 0.873936448, 0.124005415, -0.155868715, -0.279265373, 
-0.009212378, -0.928709263, -0.725480945, 0.304241419, 0.515663469, 
0.402484376, -0.454475292, 0.783130838, -0.975667025, 0.010751094, 
-0.511640117, -0.216935153, 0.775591738, -0.193554039, -0.116580603, 
0.158256198, -0.310523585, -0.310523585, -0.309633387, -0.309633387, 
-0.030602108, 0.710386067, 1.322994882, 0.087451074, -0.512265445, 
0.869643169, 0.50464826, -0.822739086, -0.458413549, 0.381219103, 
-0.318251412, 0.225388796, -0.932007398, 0.638414233), V18 = c(0.02579058, 
-0.18336127, -0.121359313, 1.965775003, -0.038194787, 0.068653149, 
-0.61198734, -0.35822157, 0.118764861, 0.47667726, 0.854343814, 
0.35998539, -0.847788599, -0.980496202, 0.778265457, -0.419994141, 
-0.595912406, 0.680469593, 0.075081352, 0.554432499, 0.625847298, 
-1.737162035, -0.098870627, 0.436621214, 0.044062818, -0.488472666, 
-0.325056355, 1.271765385, -0.942888927, 0.042387962, -0.633790817, 
-0.398751479, -0.404247869, -0.404247869, -0.403901993, -0.403901993, 
-0.504568166, -0.118368787, -2.830035229, -0.550473628, 0.118994619, 
-0.09565956, -0.798404511, 0.338821622, -0.559803243, -1.372080174, 
0.064787167, -0.668680159, 1.9265322, -0.776070595), V19 = c(0.40399296, 
-0.145783041, -2.261857095, -1.23262197, 0.803486925, -0.033193788, 
-0.045575045, 0.324504731, 0.570328167, 0.451772964, -0.221365414, 
0.707663826, -0.683192626, -0.982916082, 2.221868014, 0.432535349, 
-0.575681622, 0.025436462, -0.406866573, 0.054229515, -1.300408169, 
-2.027612322, -0.816597307, 2.177807168, 0.488602869, 0.505751034, 
-0.390933798, -1.240621935, 0.543969462, -0.277833721, 0.348415801, 
-0.145708909, -0.823373524, -0.823373524, -0.823742994, -0.823742994, 
0.355180278, 0.979287836, -1.463431688, -0.154749355, 0.57472016, 
0.944395409, 0.759710307, -1.214234428, -0.29510264, -0.273701149, 
0.613505272, -0.023599421, -0.659939173, 0.69280589), V20 = c(0.251412098, 
-0.069083135, 0.524979725, -0.208037781, 0.40854236, 0.084967672, 
-0.219632553, -0.156741852, 0.052735669, 0.203711455, -0.387226474, 
0.125991576, -0.102755942, -0.153197231, -1.582122044, 0.263450864, 
-0.113910177, -0.047021282, -2.196848025, -0.387910173, -0.13833394, 
-0.269320967, -0.307168509, -0.230983143, -0.216715254, -0.386693573, 
0.027877909, -0.522950941, 0.097307591, -0.178023367, -0.066351335, 
-0.273832367, -0.290347611, -0.290347611, -0.283263782, -0.283263782, 
0.045721127, 0.008713334, -0.20346121, -0.190119711, 0.097852692, 
0.028740125, 0.254324778, -0.00541945, 0.359392906, -0.078354633, 
-0.033522345, -0.222302592, -0.273032887, 0.235008926), V21 = c(-0.018306778, 
-0.225775248, 0.247998153, -0.108300452, -0.009430697, -0.208253515, 
-0.167716266, 1.94346534, -0.0734251, -0.246913937, -0.009301897, 
0.049923686, -0.231809239, -0.036875532, 1.151663048, 0.499624955, 
-0.024612006, -0.194795824, -0.503600329, -0.177649846, -0.295582932, 
0.143997423, 0.018701872, 1.650180361, -0.579525934, -0.403639499, 
0.067003304, -0.284375572, 0.077237434, 0.013676294, -0.245682498, 
-0.05323366, 0.046949067, 0.046949067, 0.049525687, 0.049525687, 
-0.194599935, 0.082279817, -0.076301837, -0.037708654, -0.006292714, 
0.094917307, -0.087329191, 0.401212016, 0.433349642, -0.164222415, 
-0.064906147, 0.71896107, -0.228726646, -0.05722847), V22 = c(0.277837576, 
-0.638671953, 0.771679402, 0.005273597, 0.798278495, -0.559824796, 
-0.270709726, -1.01545471, -0.268091632, -0.633752642, 0.313894411, 
0.238421512, -0.48328533, 0.074412403, 0.222181966, 1.353650486, 
0.196001953, -0.672637997, 0.984459786, -0.175073809, -0.571955007, 
0.402491661, -0.061972267, 0.200454091, -0.799228953, -0.227404004, 
0.227811928, -0.323357411, 0.457330599, 0.21373361, -0.530900256, 
-0.004760151, 0.208104855, 0.208104855, 0.206536543, 0.206536543, 
-0.335132726, 0.325782191, 0.108866913, 0.095701462, 0.009200225, 
0.294982704, 0.25831528, 1.064864254, 1.260402664, -0.247400539, 
-0.120448982, -0.17187687, -0.12352242, 0.314152998), V23 = c(-0.11047391, 
0.101288021, 0.909412262, -0.190320519, -0.13745808, -0.026397668, 
-0.154103787, 0.05750353, -0.20423267, -0.120794084, 0.027740158, 
0.009129869, 0.084667691, -0.071407433, 1.020586204, -0.25657328, 
0.013801654, -0.156857514, 2.458588576, 0.040002219, -0.050880701, 
-0.048508221, -0.103854922, -0.185352508, 0.870300215, 0.742434864, 
-0.150487225, -0.037709905, -0.038499725, 0.014461849, -0.044265397, 
-0.03147017, -0.185548347, -0.185548347, -0.18710807, -0.18710807, 
-0.078179606, -0.069107391, 0.16223094, -0.048197647, -0.129463201, 
0.011081384, -0.264775023, -0.158325436, -0.404700036, 0.059405065, 
-0.156525634, -0.166205255, -0.131025122, -0.129862928), V24 = c(0.066928075, 
-0.339846476, -0.689280956, -1.175575332, 0.141266984, -0.371426583, 
-0.780055415, -0.649709006, 1.011591802, -0.385049925, 0.500512287, 
0.99671021, 0.392830885, 0.104743753, 0.028316651, -0.065083708, 
0.103758331, -0.888386321, 0.042118897, 0.295813863, -0.304214501, 
-1.371866295, -0.370415177, 0.423073148, 0.983421493, 0.398534855, 
0.435045103, 0.347150939, 0.642521903, 0.00295086, 0.079168029, 
0.198053718, 0.00103066, 0.00103066, 0.000753014, 0.000753014, 
0.392783892, 0.020961997, -0.575624048, 0.232114939, 1.11297017, 
0.015249372, 0.118282367, 0.295505486, 0.094945523, 0.456286465, 
-0.800212851, 0.776471324, -0.929668179, 0.114283708), V25 = c(0.128539358, 
0.167170404, -0.327641834, 0.647376035, -0.206009588, -0.232793817, 
0.750136936, -0.415266566, 0.37320468, -0.069733046, 0.251367359, 
-0.767314827, 0.161134554, 0.548264725, -0.232746324, -0.039124354, 
0.364297541, -0.342413219, -0.481630824, 0.332930599, 0.072001006, 
0.390813885, 0.603200339, 0.820591262, 0.321201133, 0.249212161, 
0.72482458, 0.559639137, -0.183891335, 0.294638015, 0.50913569, 
0.565007313, 0.098815701, 0.098815701, 0.098116606, 0.098116606, 
-0.031157147, -0.044668488, 0.109794915, 0.606200749, 0.500382109, 
0.034210636, 0.173508081, -0.259369648, 0.480975977, 0.361004004, 
-0.000620392, 0.818460356, 0.181379006, -0.027812477), V26 = c(-0.189114844, 
0.125894532, -0.139096572, -0.221928844, 0.502292224, 0.105914779, 
-0.257236846, -0.051634297, -0.384157308, 0.094198834, -0.129477954, 
-0.492208295, -0.35499004, 0.104094153, -0.235557218, -0.087086473, 
-0.382260574, -0.049026729, -0.621272014, -0.220384851, -0.42223443, 
0.199963658, 0.108555873, -0.227631864, 0.149649877, 0.274404274, 
-0.33708206, -0.280158166, -0.277464019, -0.395069505, 0.288857834, 
-0.337718126, -0.552903603, -0.552903603, -0.553470969, -0.553470969, 
0.198036799, -0.243441392, 0.373813367, -0.342096829, 1.196549199, 
-0.236141102, -0.217041287, 0.754194723, -0.09068468, 0.274414146, 
-0.835203307, 0.442547455, 1.194928064, -0.259937016), V27 = c(0.133558377, 
-0.008983099, -0.055352794, 0.062722849, 0.21942223, 0.253844225, 
0.03450743, -1.206921081, 0.011747356, 0.246219305, 0.042849871, 
0.042472442, 0.026415549, 0.021491058, -0.164777512, -0.1809975, 
0.092809187, 0.079692399, 0.39205329, 0.022298436, 0.086553398, 
0.016370643, -0.040520706, 0.336634447, 0.707518836, 0.359969356, 
0.016368379, 0.042335258, 0.182687486, 0.081461117, -0.022704982, 
0.029057402, -0.073288084, -0.073288084, -0.078305502, -0.078305502, 
-0.175347301, 0.149180325, 0.050552197, 0.036769605, -0.048220435, 
0.128290673, 0.094311913, 0.04666377, 0.319222973, -0.002498362, 
0.131001421, 0.142757247, 0.000531332, 0.11875364), V28 = c(-0.021053053, 
0.014724169, -0.059751841, 0.061457629, 0.215153147, 0.081080257, 
0.005167769, -1.085339188, 0.14240433, 0.083075649, 0.016253262, 
-0.054337388, 0.042422089, 0.021293311, -0.030153637, 0.129394059, 
0.037050517, 0.131023789, 0.949594246, 0.007602256, 0.063498649, 
-0.014605328, -0.011417815, 0.250475352, 0.014599752, 0.243231672, 
0.030041191, 0.0288223, 0.152664645, 0.024220349, 0.011836231, 
0.004452631, 0.023307045, 0.023307045, 0.025427378, 0.025427378, 
-0.203616156, 0.120556908, 0.005105559, 0.007479961, 0.005093622, 
0.11798599, -0.033041296, 0.093947918, 0.135599925, 0.017108847, 
0.06289627, 0.21923761, 0.019910623, -0.008956298), Amount = c(149.62, 
2.69, 378.66, 123.5, 69.99, 3.67, 4.99, 40.8, 93.2, 3.68, 7.8, 
9.99, 121.5, 27.5, 58.8, 15.99, 12.99, 0.89, 46.8, 5, 231.71, 
34.09, 2.28, 22.75, 0.89, 26.43, 41.88, 16, 33, 12.99, 17.28, 
4.45, 6.14, 6.14, 1.77, 1.77, 30.49, 1.8, 20.53, 6.54, 29.89, 
2.35, 14.8, 9.1, 15.99, 21.34, 18.95, 9.99, 30.9, 20.22), Class = c(0L, 
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
0L)), row.names = c(NA, 50L), class = "data.frame")
### end of structure 
library(caret)
#> Loading required package: lattice
#> Loading required package: ggplot2
index <- createDataPartition(daten$Class, p = 0.8, list = FALSE)
#> Error in cut.default(y, unique(quantile(y, probs = seq(0, 1, length = groups))), : invalid number of intervals

Created on 2020-04-01 by the reprex package (v0.3.0)

@dromano Thats weird. Did you use the dataset i referenced to? I ran the same code on my machine and the createDataPartition command worked

Could you try it with the data I posted and see what happens?

I did, i got the exact same error. Why dont you try to use the csv i shared the link to? I works with that csv. I fixed it thanks

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.