当我尝试使用分类器时,出现错误:
ValueError:无法将字符串转换为float:'4/1/2010'
# Load the Pandas libraries with alias 'pd'
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
from sklearn.linear_model import LinearRegression
from sklearn.metrics import mean_squared_error
from math import sqrt
from ml_metrics import rmse
# Read data from file 'filename.csv'
# (in the same directory that your python process is based)
# Control delimiters, rows, column names with read_csv (see later)
data = pd.read_csv("NASDAQ.csv")
data.dropna(inplace=True)
#df.drop_duplicates(inplace=True)
nInstances, nAttributes = data.shape
if data.shape[0]:
train = data[:1762]
test = data[1762:]
x_train= train.values[:,0:nAttributes-1]
y_train= train.values[:,nAttributes-1]
# classifiers Linear Regression, Logistic Regression, kNN, SVM και MLP
clf = LinearRegression().fit(x_train, y_train)
能否请您检查一下并帮助我找出问题出在哪里?