<jupyter_start><jupyter_text>Linear Regression<jupyter_code>from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression
USAHousing.columns
X = USAHousing[['Avg. Area Income', 'Avg. Area House Age', 'Avg. Area Number of Rooms',
       'Avg. Area Number of Bedrooms', 'Area Population', 'Address']];
X.describe()
y = USAHousing['Price'];
y.describe()
lm = LinearRegression()
X = X.apply(pd.to_numeric, errors='coerce')
y = y.apply(pd.to_numeric, errors='coerce')
X.fillna(0, inplace=True)
y.fillna(0, inplace=True)

X_train,X_test,y_train,y_test = train_test_split(X,y,test_size = 0.4,random_state=100)
lm.fit(X_train,y_train)
print(lm.intercept_)
coeff_USA = pd.DataFrame(lm.coef_,X.columns,columns=['Co-efficient'])
coeff_USA
from sklearn.datasets import load_boston
boston = load_boston()
print(boston.DESCR)
boston_df = boston.data
predictions = lm.predict(X_test)
plt.scatter(y_test,predictions)
sns.distplot((y_test-predictions),hist=50)
from sklearn import metrics
metrics.mean_absolute_error(y_test,predictions)
metrics.mean_squared_error(y_test,predictions)
np.sqrt(metrics.mean_squared_error(y_test,predictions))<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13076278290025148, 'fraction_numerical': 0.0075440067057837385, 'mean_word_length': 8.401574803149606, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '69845', 'license': 'MIT', 'n_tokens_mistral': 464, 'n_tokens_neox': 446, 'n_words': 75, 'path': '08. Linear Regression/Linear Regression.ipynb', 'repo_name': 'markpairdha/Python-For-DataScience-and-Machine-Learning-BootCamp', 'size': '1193'}