Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save saimadhu-polamuri/dace984e52fbb800efdd6511a1896c5c to your computer and use it in GitHub Desktop.
Save saimadhu-polamuri/dace984e52fbb800efdd6511a1896c5c to your computer and use it in GitHub Desktop.
## import the required libraries
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from statistics import mean
from sklearn.linear_model import LinearRegression, Ridge, Lasso
from sklearn.model_selection import train_test_split, cross_val_score
## load the dataset
df = pd.read_csv("kc_house_data.csv")
## dropping unnecessary columns
df = df.drop(['id', 'date', 'zipcode'], axis=1)
## separating the target variable
X = df.drop('price', axis=1)
y = df['price']
## splitting the data into train and test (70-30 ratio)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.30)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment