{
  "id": 9476,
  "title": "can anyone help me with glmnet R code?",
  "url": "/competitions/acquire-valued-shoppers-challenge/discussion/9476",
  "author_name": "Sungsik James Ji",
  "post_date": "2014-06-16T06:05:03.557000",
  "votes": 0,
  "comment_count": 0,
  "views": 1454,
  "content": "<p>I kept getting error msg when i type following code.</p>\n<p>Can anyone tell me what's wrong??</p>\n\n\n<p>model &lt;- glmnet(xTrain, target, family = &quot;binomial&quot;, alpha = 0, lambda = 2^17)</p>\n<p>xTrain has three column - chain, offer, market with 160,057 rows<br>target is a &quot;T or F&quot; column that represents repeat binomial.</p>\n\n<p>&quot;Warning message:</p>\n<p>In Ops.factor(left, right) : * not meaningful for factors<br>Error in drop(y %*% rep(1, nc)) : <br> &#54632;&#49688; 'drop'&#47484; &#50948;&#54620; &#47700;&#49548;&#46300; &#49440;&#53469;&#49884; &#51064;&#49688; 'x'&#47484; &#54217;&#44032;&#54616;&#45716;&#45936; &#50724;&#47448;&#44032; &#48156;&#49373;&#54664;&#49845;&#45768;&#45796;: Error in y %*% rep(1, nc) : <br> requires numeric/complex matrix/vector arguments&quot;</p>\n<p>(sorry that its in Korean)</p>\n\n<p><br>I was trying to use following thread coding for R script<br>&quot;http://www.kaggle.com/c/acquire-valued-shoppers-challenge/forums/t/7917/performance-of-logistic-regression-on-features-described-by-triskelion/43307&quot;</p>\n\n\n<p>------------actual code</p>\n<p>library(glmnet)</p>\n<p>csvTrainfile &lt;- &quot;data/train.csv&quot;<br>csvTestfile &lt;- &quot;data/test.csv&quot;<br>testHistoryfile &lt;- &quot;data/testHistory.gz&quot;</p>\n<p>testHistory &lt;- read.csv(testHistoryfile)<br>numTest &lt;- nrow(testHistory)</p>\n<p>training &lt;- read.csv(csvTrainfile)<br>target &lt;- training$repeter<br>training[is.na(training)] &lt;- 0<br>xTrain &lt;- as.matrix(training[, (2:4)])</p>\n<p>test &lt;- read.csv(csvTestfile)<br>test[is.na(test)] &lt;- 0<br>xTest &lt;- as.matrix(test[, (2:4)])</p>\n<p>model &lt;- glmnet(xTrain, target, family = &quot;binomial&quot;, alpha = 0, lambda = 2^17)</p>",
  "messages": [
    {
      "id": 49181,
      "postDate": "2014-06-16T06:05:03.557Z",
      "content": "<p>I kept getting error msg when i type following code.</p>\n<p>Can anyone tell me what's wrong??</p>\n\n\n<p>model &lt;- glmnet(xTrain, target, family = &quot;binomial&quot;, alpha = 0, lambda = 2^17)</p>\n<p>xTrain has three column - chain, offer, market with 160,057 rows<br>target is a &quot;T or F&quot; column that represents repeat binomial.</p>\n\n<p>&quot;Warning message:</p>\n<p>In Ops.factor(left, right) : * not meaningful for factors<br>Error in drop(y %*% rep(1, nc)) : <br> &#54632;&#49688; 'drop'&#47484; &#50948;&#54620; &#47700;&#49548;&#46300; &#49440;&#53469;&#49884; &#51064;&#49688; 'x'&#47484; &#54217;&#44032;&#54616;&#45716;&#45936; &#50724;&#47448;&#44032; &#48156;&#49373;&#54664;&#49845;&#45768;&#45796;: Error in y %*% rep(1, nc) : <br> requires numeric/complex matrix/vector arguments&quot;</p>\n<p>(sorry that its in Korean)</p>\n\n<p><br>I was trying to use following thread coding for R script<br>&quot;http://www.kaggle.com/c/acquire-valued-shoppers-challenge/forums/t/7917/performance-of-logistic-regression-on-features-described-by-triskelion/43307&quot;</p>\n\n\n<p>------------actual code</p>\n<p>library(glmnet)</p>\n<p>csvTrainfile &lt;- &quot;data/train.csv&quot;<br>csvTestfile &lt;- &quot;data/test.csv&quot;<br>testHistoryfile &lt;- &quot;data/testHistory.gz&quot;</p>\n<p>testHistory &lt;- read.csv(testHistoryfile)<br>numTest &lt;- nrow(testHistory)</p>\n<p>training &lt;- read.csv(csvTrainfile)<br>target &lt;- training$repeter<br>training[is.na(training)] &lt;- 0<br>xTrain &lt;- as.matrix(training[, (2:4)])</p>\n<p>test &lt;- read.csv(csvTestfile)<br>test[is.na(test)] &lt;- 0<br>xTest &lt;- as.matrix(test[, (2:4)])</p>\n<p>model &lt;- glmnet(xTrain, target, family = &quot;binomial&quot;, alpha = 0, lambda = 2^17)</p>"
    }
  ],
  "comments": [],
  "raw_markdown_by_id": {
    "49181": ""
  }
}