Error while performing classification using gradient boosting in R

I am currently solving one classification problem using gradient boosting when I am creating the model it giving me an error.

``````My data
str(train_final)
'data.frame':   614 obs. of  11 variables:
\$ Loan_Status      : Factor w/ 2 levels "N","Y": 2 1 2 2 2 2 2 1 2 1 ...
\$ Credit_History   : int  1 1 1 1 1 1 1 0 1 1 ...
\$ Property_Area    : Factor w/ 3 levels "Rural","Semiurban",..: 3 1 3 3 3 3 3 2 3 2 ...
\$ CoapplicantIncome: num  0 1508 0 2358 0 ...
\$ ApplicantIncome  : num  5849 4583 3000 2583 6000 ...
\$ LoanAmount       : num  142 128 66 120 141 ...
\$ Married          : Factor w/ 2 levels "No","Yes": 1 2 2 2 1 2 2 2 2 2 ...
\$ Education        : Factor w/ 2 levels "Graduate","Not Graduate": 1 1 1 2 1 1 2 1 1 1 ...
\$ Dependents       : Factor w/ 4 levels "0","1","2","3+": 1 2 1 1 1 3 1 4 3 2 ...
\$ Gender           : Factor w/ 2 levels "Female","Male": 2 2 2 2 2 2 2 2 2 2 ...
\$ Self_Employed    : Factor w/ 2 levels "No","Yes": 1 1 2 1 1 2 1 1 1 1 ..

Model
gbm1<-gbm(Loan_Status ~ .,distribution = "bernoulli" ,data=train_final)
``````

Error in gbm.fit(x, y, offset = offset, distribution = distribution, w = w, :
Bernoulli requires the response to be in {0,1}

Hi

you should do

gbm1<-gbm((unclass(Loan_Status)-1) ~ .,distribution = “bernoulli” ,data=train_final)

do not forget to do the same for predict

Alain