Introduction
In this, you will specify and fit a linear model to a few features of the housing data to predict housing prices. Next, we will analyze the error of the model and brainstorm ways to improve the model’s performance. Finally, we’ll delve deeper into the implications of predictive modeling within the Cook County Assessor’s Office (CCAO) case study, especially because statistical modeling is how the CCAO valuates properties. Given the history of racial discrimination in housing policy and property taxation in Cook County, consider the impacts of your modeling results as you work through this assignment - and think about what fairness might mean to property owners in Cook County. After this homework, you should be comfortable with: - Implementing a data processing pipeline using pandas - Using scikit-learn to build and fit linear models
Import All Related Libraries
import numpy as np
import pandas as pd
from pandas.api.types import CategoricalDtype
%matplotlib inline
import matplotlib.pyplot as plt
import seaborn as sns
import warnings
warnings.filterwarnings("ignore")
import zipfile
import os
from ds100_utils import run_linear_regression_test
# Plot settings
plt.rcParams['figure.figsize'] = (12, 9)
plt.rcParams['font.size'] = 12
Read Data
# Reload the data
full_data = pd.read_csv("cook_county_train.csv")
Split dataset
# Process the data using the pipeline for the first model
np.random.seed(1337)
train_m1, test_m1 = train_test_split(full_data)
# A custom function that applies log transformation
def log_transform(data, col):
data['Log ' + col] = np.log(data[col])
return data
m1_pipelines = [
(remove_outliers, None, {
'variable': 'Sale Price',
'lower': 499,
}),
(log_transform, None, {'col': 'Sale Price'}),
(add_total_bedrooms, None, None),
(select_columns, ['Log Sale Price', 'Bedrooms'], None)
]
X_train_m1, y_train_m1 = process_data_gm(train_m1, m1_pipelines, 'Log Sale Price')
X_test_m1, y_test_m1 = process_data_gm(test_m1, m1_pipelines, 'Log Sale Price')
Linear Model
#creating linear model
from sklearn.linear_model import LinearRegression
reg = LinearRegression()
Fit Into Model
reg.fit(x_train_m1, y_train_m1)
Find the score
reg.score(x_test_m1, y_test_m1)
If you need any programming assignment help in Machine Learning, Machine Learning project or Machine Learning homework then we are ready to help you.
Send your request at realcode4you@gmail.com and get instant help with an affordable price.
We are always focus to delivered unique or without plagiarism code which is written by our highly educated professional which provide well structured code within your given time frame. If you are looking other programming language help like C, C++, Java, Python, PHP, Asp.Net, NodeJs, ReactJs, etc. with the different types of databases like MySQL, MongoDB, SQL Server, Oracle, etc. then also contact us.
コメント