Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 205399

Why does my Naive Bayes classifier error out with a Density.default when I can perform a density plot?

$
0
0

I am trying to perform a naive bayes classifier and get the following error:

Error in density.default(x, na.rm = TRUE, ...) : 
  need at least 2 points to select a bandwidth automatically

I'm only getting this error when I include a numeric variable and oddly enough can perform a density plot on the same numeric variable. The classifier works up until I include the numeric variable and I have no missing data.

Below is my implementation of the predictor:

pred1 <- naive_bayes(x = reg_pred_train[1:4], y = reg_pred_train$WeightedScore, 
                     usekernel = TRUE, laplace = 5)

Packages include dplyr and naivebayes. Below is a sample of the data:

Gender   Coalesce Race  AgeBracket  VP                WeightedScore      
 F:755   Asian   :  15   18-25: 13   Min.   :0.1162    Min.   : 0.000   
 M:878   Black   :  91   25-35: 68   1st Qu.:0.8905    1st Qu.: 5.000    
 U:  5   Hispanic:  24   35-50:258   Median :0.9379    Median : 6.000    
         Other   :   6   50-65:449   Mean   :0.8970    Mean   : 6.145    
         Unknown :  49   65-75:461   3rd Qu.:0.9618    3rd Qu.: 8.000    
         White   :1453   75+  :389   Max.   :0.9933    Max.   :10.000    

Viewing all articles
Browse latest Browse all 205399

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>