In this example we will show how to predict values when a data set is scaled in Python.
Source Code
import pandas as pd
from sklearn import linear_model
from sklearn.preprocessing import StandardScaler
df = pd.read_csv("advertising.csv")
X = df[["TV", "radio", "newspaper"]]
y = df["sales"]
scaler = StandardScaler()
scaled_X = scaler.fit_transform(X)
reg = linear_model.LinearRegression().fit(scaled_X, y)
scaled = scaler.transform([[50, 30, 20]])
predict_sales = reg.predict([scaled[0]])
print(predict_sales)
Output:
[10.86227229]