<jupyter_start><jupyter_text>Linear Regression with 2 Variables==============Predicting the body weight of the Species given the weight of its brain-----------<jupyter_code>import matplotlib
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns
import sklearn
import numpy as np
%matplotlib inline<jupyter_output><empty_output><jupyter_text>1.Import and Visualize data<jupyter_code>data_frame = pd.read_fwf('challenge_dataset2.txt')
x_values = data_frame[['Brain']]
y_values = data_frame[['Body']]
sns.regplot(data=data_frame,fit_reg=False,x='Brain',y='Body')<jupyter_output><empty_output><jupyter_text>2.Fit 2D Regression Model<jupyter_code>from sklearn.model_selection import train_test_split
x_train,x_test,y_train,y_test=train_test_split(x_values,y_values,test_size=0.1)
print "Train - Test Split =",len(x_train),":",len(x_test)
from sklearn.linear_model import LinearRegression
model=LinearRegression()
model.fit(x_train,y_train)
print "Score:",model.score(x_test.values,y_test.values)<jupyter_output>Score: -1.54482998101<jupyter_text>3.Plot and Visualize Results<jupyter_code>x_line = np.arange(5,25).reshape(-1,1)
sns.regplot(x_values, y_values, data=data_frame, fit_reg=False)
plt.plot(x_values, model.predict(x_values))
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1325581395348837, 'fraction_numerical': 0.01937984496124031, 'mean_word_length': 9.84873949579832, 'pattern_counts': {'":': 1, '<': 16, '<?xml version=': 0, '>': 16, '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': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '621649', 'license': 'Apache-2.0', 'n_tokens_mistral': 503, 'n_tokens_neox': 480, 'n_words': 79, 'path': 'Challenge.ipynb', 'repo_name': 'suraj-shanbhag/Linear-Regression-Challenge', 'size': '1290'}