Can anyone help me, please? I've been stuck on this question for a while now. I've been told this can't be done with regression, it has to be classification. Is that true? This is the code:
import pandas as pd
import numpy as np
import sklearn
from sklearn import linear_model
data = pd.read_csv("InsuranceCostCalculator/Insurance.csv")
data = data[["age", "sex", "bmi", "children", "smoker", "region", "charges",]]
predict = ('charges')
X = np.array(data.drop([predict], 1)) #X is our training data
Y = np.array(data[predict])
x_train, x_test, y_train, y_test = sklearn.model_selection.train_test_split(X, Y, test_size=0.1)
Linear = linear_model.LinearRegression()
Linear.fit(x_train, y_train)
prediction = Linear.predict(x_test)
for x in range(len(prediction)):
print(prediction[x], x_test[x], y_test[x])