title: ValueError: could not convert string to float:
body: <p>I am following a this tutorial to write a Naive Bayes Classifier:
  <a href="http://machinelearningmastery.com/naive-bayes-classifier-scratch-python/" rel="nofollow noreferrer">http://machinelearningmastery.com/naive-bayes-classifier-scratch-python/</a></p>
  
  <p>I keep getting this error:</p>
  
  <pre><code>dataset[i] = [float(x) for x in dataset[i]]
  ValueError: could not convert string to float: 
  </code></pre>
  
  <p>Here is the part of my code where the error occurs: </p>
  
  <pre><code>def loadDatasetNB(filename):
      lines = csv.reader(open(filename, "rt"))
      dataset = list(lines)
      for i in range(len(dataset)):
          dataset[i] = [float(x) for x in dataset[i]]
      return dataset
  </code></pre>
  
  <p>And here is how the file is called:</p>
  
  <pre><code>def NB_Analysis():
      filename = 'fvectors.csv'
      splitRatio = 0.67
      dataset = loadDatasetNB(filename)
      trainingSet, testSet = splitDatasetNB(dataset, splitRatio)
      print('Split {0} rows into train={1} and test={2} rows').format(len(dataset), len(trainingSet), len(testSet))
      # prepare model
      summaries = summarizeByClassNB(trainingSet)
      # test model
      predictions = getPredictionsNB(summaries, testSet)
      accuracy = getAccuracyNB(testSet, predictionsNB)
      print('Accuracy: {0}%').format(accuracy)
  
  NB_Analysis()
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/wIEYG.png" rel="nofollow noreferrer">My file fvectors.csv looks like this</a></p>
  
  <p>What is going wrong here and how do I fix it?</p>