While practicing Simple Linear Regression Model I got this error:
ValueError: Expected 2D array, got scalar array instead:
array=60.
Reshape your data either using array.reshape(-1, 1) if your data has a single
feature or array.reshape(1, -1) if it contains a single sample.
This is my code (Python 3.7):
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from sklearn.linear_model import LinearRegression
from sklearn.metrics import r2_score
data = pd.read_csv("hw_25000.csv")
hgt = data.Height.values.reshape(-1,1)
wgt = data.Weight.values.reshape(-1,1)
regression = LinearRegression()
regression.fit(hgt,wgt)
print(regression.predict(60))