topepo / caret

caret (Classification And Regression Training) R package that contains misc functions for training and plotting classification and regression models
http://topepo.github.io/caret/index.html
1.62k stars 632 forks source link

Something is wrong; all the Accuracy metric values are missing: #1183

Open Abou29 opened 3 years ago

Abou29 commented 3 years ago

Salut, j'ai besoin d'aide svp. J'ai un blocage avec le problème de machine learning suivant:

bank_data=read.csv("bank.csv", sep=";")

library("caret")
dummy_variables = dummyVars(~., bank_data)
dummy_variables_data=predict(dummy_variables, bank_data)
dummy_variables_data=as.data.frame(dummy_variables_data)
dummy_variables_data

fonction<-function(x){
  if (x==1){
    return('yes')
  }else{
    return('no')
  }
}

dummy_variables_data['Souscription']=apply(as.data.frame(dummy_variables_data$yyes), 1 ,fonction)
dummy_variables_data[,c(52,53,55)]=NULL

# Création des jeux de donnéees d'entrainement et de test  
set.seed(3033)
training_size=floor(0.7*nrow(dummy_variables_data))
indices=sample(1:nrow(dummy_variables_data), training_size)
data_bank.train=dummy_variables_data[indices,]
data_bank.test=dummy_variables_data[-indices,]

#Normalisation de données 
data_preprocess_value=preProcess(data_bank.train, method = c("center","scale"))
data_bank.train.scaled=predict(data_preprocess_value, data_bank.train)
data_bank.test.scaled=predict(data_preprocess_value, data_bank.test)

set.seed(3033)
trainControl_data=trainControl(method="repeatedcv", number=10, repeats=3)
naive_bayes_desequilibree=train(Souscription~., data=data_bank.train.scaled, method="nb", trControl=trainControl_data, preProcess=NULL)

Voici le résultat que j'obtiens: 
Something is wrong; all the Accuracy metric values are missing:
    Accuracy       Kappa    
 Min.   : NA   Min.   : NA  
 1st Qu.: NA   1st Qu.: NA  
 Median : NA   Median : NA  
 Mean   :NaN   Mean   :NaN  
 3rd Qu.: NA   3rd Qu.: NA  
 Max.   : NA   Max.   : NA  
 NA's   :2     NA's   :2    
Erreur : Stopping
De plus : There were 50 or more warnings (use warnings() to see the first 50)
topepo commented 3 years ago

Can you please provide a minimal reprex (reproducible example)? The goal of a reprex is to make it as easy as possible for me to recreate your problem so that I can fix it: please help me help you!

If you've never heard of a reprex before, start by reading "What is a reprex", and follow the advice further down that page.