title: Lasso: Cross-validation for glmnet
body: <p>I am using <code>cv.glmnet()</code> to perform cross-validation, by default <code>10-fold</code></p>
  
  <pre><code>library(Matrix)
  library(tm)
  library(glmnet)
  library(e1071)
  library(SparseM)
  library(ggplot2)
  
  trainingData &lt;- read.csv("train.csv", stringsAsFactors=FALSE,sep=",", header = FALSE)
  testingData  &lt;- read.csv("test.csv",sep=",", stringsAsFactors=FALSE, header = FALSE)
  
  x = model.matrix(as.factor(V42)~.-1, data = trainingData)
  crossVal &lt;- cv.glmnet(x=x, y=trainingData$V42, family="multinomial", alpha=1)
  plot(crossVal)
  </code></pre>
  
  <p>I am having the following error message</p>
  
  <pre><code>Error in lognet(x, is.sparse, ix, jx, y, weights, offset, alpha, nobs,  : 
    one multinomial or binomial class has 1 or 0 observations; not allowed
  </code></pre>
  
  <p>But as it is shown below, I don't seem to have an observation level with counts of either <code>0</code> or <code>1</code>. </p>
  
  <pre><code>&gt;table(trainingData$V42)
  
         back buffer_overflow       ftp_write    guess_passwd            imap         ipsweep            land      loadmodule        multihop 
          956              30               8              53              11            3599              18               9               7 
      neptune            nmap          normal            perl             phf             pod       portsweep         rootkit           satan 
        41214            1493           67343               3               4             201            2931              10            3633 
        smurf             spy        teardrop     warezclient     warezmaster 
         2646               2             892             890              20 
  </code></pre>
  
  <p>Any pointers?</p>