I'm trying to build a Linear Regression model for a dataset. After splitting the data into train and test, I get the below error:
ValueError: could not convert string to float: '?' Does that mean, there is null value or a float value in the dataset?
As I'm new to Python, I don't understand how to rectify this. Could anyone help me on this?
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn import linear_model
df = pd.read_csv('https://archive.ics.uci.edu/ml/machine-learning-databases/breast-cancer-wisconsin/breast-cancer-wisconsin.data', names = ['ID Number', 'Clump Thickness', 'Uniformity of Cell Size', 'Uniformity of Cell Shape', 'Marginal Adhesion', 'Single Epithelial Cell Size', 'Bare Nuclei', 'Bland Chromatin', 'Normal Nucleoli', 'Mitoses', 'Class'])
X = df.iloc[:, 0:9].values
y = df.iloc[:, 10].values
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.4, random_state = 4)
print(X_train.shape)
print(y_train.shape)
print(X_test.shape)
print(y_test.shape)
lr = linear_model.LinearRegression()
lr.fit(X_train, y_train)
object
. TypeX.dtype
and check datatype of each column in your data. – Sociopath