-1

I'm writing Python code to predict taxi demand for NYC. My data is shown as bellowenter image description here

after I use SVR to predict the taxi demand. I have the following error: Could not convert string to float: '19:40:00'

My code:

x_names = ['pickup_cluster','pickup_datetime','dayofyear','average temperature',       'precipitation','snow fall']
x = taxi_data[x_names]
y= taxi_data['Count']

xtrain, xtest, ytrain, ytest=sklearn.model_selection.train_test_split(x, y, test_size=0.1)

regressor = SVR(kernel='rbf', gamma='auto', C=0.1, epsilon=2)
regressor.fit(xtrain, ytrain)
acc = regressor.score(xtest, ytest)
print("Accuracy for SVR: ", acc)
AMC
  • 2,642
  • 7
  • 13
  • 35
  • 1
    _My data is shown as bellow_ No, please provide a [mcve], and please do not share information as images unless absolutely necessary. See: https://meta.stackoverflow.com/questions/303812/discourage-screenshots-of-code-and-or-errors, https://idownvotedbecau.se/imageofcode, https://idownvotedbecau.se/imageofanexception/. What do you understand from that error message? – AMC May 04 '20 at 01:45

1 Answers1

1

Answer can be found here: Convert python datetime to timestamp in milliseconds

The error says you cannot convert the string to a float as it has ":" in it, not allowing it to be directly converted to a float. Hence, format the time and get the time as a float using the link provided

Daniel Poh
  • 129
  • 1
  • 10