<jupyter_start><jupyter_text>I'll predict the effect of house size and number of rooms on the house price.Hypothesis 1: The house price increases with increase in house size. First, I'll only focus on the effect of independent variable house size on the dependent variable house price.<jupyter_code>import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
dataset = pd.read_csv('../input/programming-assignment-linear-regression/ex1data2.csv')
X = dataset.iloc[:, [0]].values
y = dataset.iloc[:, -1].values
from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.2, random_state = 0)<jupyter_output><empty_output><jupyter_text>Linear Regression<jupyter_code>from sklearn.linear_model import LinearRegression
regressor = LinearRegression()
regressor.fit(X_train, y_train)
from sklearn.linear_model import LinearRegression
regressor = LinearRegression()
regressor.fit(X_train, y_train)
y_lin_pred = regressor.predict(X_test)
from sklearn.metrics import r2_score
r2_score(y_test, y_lin_pred)
print(regressor.intercept_)
print(regressor.coef_)
plt.scatter(X_train, y_train, color = 'red')
plt.plot(X_train, regressor.predict(X_train))
plt.title('House price vs House size')
plt.xlabel('House Size')
plt.ylabel('House Price')
plt.show()<jupyter_output><empty_output><jupyter_text>-> Hypothesis 1 is correct as house price increases with house size.-> If the house size increases by 500 sq. units, then the price increases by 125.101 units.-> The predicted price of land is 86935.2824 units.Hypothesis 2: The house price increases with increase in house size and number of bedrooms.<jupyter_code>X = dataset.iloc[:, [0, 1]].values
y = dataset.iloc[:, -1].values
from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.2, random_state = 0)
from sklearn.linear_model import LinearRegression
regressor = LinearRegression()
regressor.fit(X_train, y_train)
y_lin_pred = regressor.predict(X_test)
from sklearn.metrics import r2_score
r2_score(y_test, y_lin_pred)
print(regressor.intercept_)
print(regressor.coef_)<jupyter_output>90561.37024100646
[  125.85346026 -1596.9314267 ]
{'fraction_non_alphanumeric': 0.09648331830477908, 'fraction_numerical': 0.034265103697024346, 'mean_word_length': 6.651724137931034, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '82738', 'license': 'MIT', 'n_tokens_mistral': 817, 'n_tokens_neox': 742, 'n_words': 207, 'path': "Multiple Linear Regression/Effect of house size and rooms' no. on house price/effect-of-house-size-and-rooms-no-on-house-price.ipynb", 'repo_name': 'aditi2707/Machine-Learning-from-Kaggle', 'size': '2218'}