mercredi 10 janvier 2018

Random Splitt of Data in R using set.seed[123]

I want to a Regression tree and a random forest to a certain training sample. My Data set has 1424 entries and 11 Variables.

set.seed(123)
random = sample(1:n, floor(n)/2)
training_sample=test_dropped[random,]
testing_sample=test_dropped[-random,]

The 3 lines above always create a training_sample that has just 3 entries.

If I use random = sample(1:nrow(test_dropped), floor(nrow(test_dropped))/2) this to create the random variable it splits my dataset of 1424 entries exactly in half..

what am I missing that i don´t understand why that happens and why that might be important ?

Thank you :)




Aucun commentaire:

Enregistrer un commentaire