<jupyter_start><jupyter_text>1.Load the dataset into the pandas data frame. To do so, you first need to import the pandas library, and then, use the function pd.read_csv(), as shown below:<jupyter_code>import pandas as pd 
#reading the data into the dataframe into the object data
df = pd.read_csv("https://raw.githubusercontent.com/TrainingByPackt/Data-Science-with-Python/master/Chapter01/Data/USA_Housing.csv", header=0)<jupyter_output><empty_output><jupyter_text>2.	Create a variable X to store the independent features. Use the drop()function to include all features but the dependent or the target variable, which in this case is named Price. Then, print out the top 5 instances of the variable<jupyter_code>X = df.drop('Price', axis=1)
X.head()<jupyter_output><empty_output><jupyter_text>3.	Print the shape of your new created feature matrix using the command X.shape. The first value indicates the number of observations in the dataset (5000), and the second value represents the number of features (6).<jupyter_code>X.shape<jupyter_output><empty_output><jupyter_text>4. Similarly, we will create a variable y that will store the target values. We will just use indexing to grab only the target column. Indexing allows you to access a section of a larger element. In this case, we want to grab the column named Price from the data frame df. Then, print out the top 10 values of the variable.<jupyter_code>y = df['Price']
y.head(10)<jupyter_output><empty_output><jupyter_text>5.	Print the shape of your new variable using the command: y.shape. The shape should be one-dimensional with length equal to the number of observations (5000) only.<jupyter_code>y.shape<jupyter_output><empty_output><jupyter_text>6.	Split the train and test with 80:20 proportion. To do so, use train_test_split() function from sklearn.model_selection package.<jupyter_code>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>7.	Print the shape of X_train, X_test, y_train, y_test.<jupyter_code>print("X_train : ",X_train.shape)
print("X_test : ",X_test.shape)
print("y_train : ",y_train.shape)
print("y_test : ",y_test.shape)<jupyter_output>X_train :  (4000, 6)
X_test :  (1000, 6)
y_train :  (4000,)
y_test :  (1000,)
{'fraction_non_alphanumeric': 0.09168808911739502, 'fraction_numerical': 0.021422450728363324, 'mean_word_length': 6.012012012012012, 'pattern_counts': {'":': 0, '<': 28, '<?xml version=': 0, '>': 28, 'https://': 1, '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': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '655956', 'license': 'MIT', 'n_tokens_mistral': 784, 'n_tokens_neox': 739, 'n_words': 263, 'path': 'Chapter01/Excercises/Excercise_12_Train_Test_Split.py.ipynb', 'repo_name': 'TrainingByPackt/Master-Data-Science-with-Python-', 'size': '2334'}