Skip to content

Instantly share code, notes, and snippets.

@aricooperdavis
aricooperdavis / 3d_regression_example.py
Last active February 2, 2024 13:13
Example of 3D plots illustrating Linear Regression with 2 features and 1 target
import matplotlib.pyplot as plt
import numpy as np
import sklearn.linear_model
from mpl_toolkits.mplot3d import Axes3D
X_train = np.random.rand(2000).reshape(1000,2)*60
y_train = (X_train[:, 0]**2)+(X_train[:, 1]**2)
X_test = np.random.rand(200).reshape(100,2)*60
y_test = (X_test[:, 0]**2)+(X_test[:, 1]**2)