title: TypeError: data should be an RDD of LabeledPoint, but got <type 'numpy.ndarray'>
body: <p>I get the error:</p>
  
  <pre><code>TypeError: data should be an RDD of LabeledPoint, but got &lt;type 'numpy.ndarray'&gt;
  </code></pre>
  
  <p>when I execute:</p>
  
  <pre><code>import sys
  import numpy as np
  from pyspark import SparkConf, SparkContext
  from pyspark.mllib.classification import LogisticRegressionWithSGD
  
  
  conf = (SparkConf().setMaster("local")
  .setAppName("Logistic Regression")
  .set("spark.executor.memory", "1g"))
  sc = SparkContext(conf = conf) 
  
  
  def mapper(line):
      feats = line.strip().split(",") 
      label = feats[len(feats) - 1]       # Last column is the label
      feats = feats[2: len(feats) - 1]    # remove id and type column
      feats.insert(0,label)
      features = [ float(feature) for feature in feats ] # need floats
      return np.array(features)
  
  data = sc.textFile("test.csv")
  parsedData = data.map(mapper)
  
  # Train model
  model = LogisticRegressionWithSGD.train(parsedData)
  </code></pre>
  
  <p>I get the error on <code>model = LogisticRegressionWithSGD.train(parsedData)</code> line.</p>
  
  <p><code>parsedData</code> is supposed to be an RDD. I am not sure why I am getting this.</p>
  
  <p>Github link to <a href="https://github.com/samarthbhargav/spark-example/blob/master/run-spark-ex.py" rel="nofollow noreferrer">full source code</a></p>