<jupyter_start><jupyter_text>Split Data Into Training And Test Sets<jupyter_code>import numpy as np
import matplotlib.pyplot as plt
import pandas as pd

import warnings
warnings.filterwarnings("ignore")

# fetch yahoo data
import yfinance as yf
yf.pdr_override()
# input
symbol = 'AMD'
start = '2014-01-01'
end = '2018-08-27'

# Read data 
dataset = yf.download(symbol,start,end)

# Only keep close columns 
dataset.head()
dataset['Increase_Decrease'] = np.where(dataset['Volume'].shift(-1) > dataset['Volume'],1,0)
dataset['Buy_Sell_on_Open'] = np.where(dataset['Open'].shift(-1) > dataset['Open'],1,0)
dataset['Buy_Sell'] = np.where(dataset['Adj Close'].shift(-1) > dataset['Adj Close'],1,0)
dataset['Returns'] = dataset['Adj Close'].pct_change()
dataset = dataset.dropna()
dataset.tail()
from sklearn.preprocessing import StandardScaler
from sklearn.model_selection import train_test_split
X = dataset.drop(['Adj Close'], axis=1)
Y = dataset['Adj Close']
X_train, X_test, y_train, y_test = train_test_split(X, 
                                                    Y, 
                                                    test_size=0.1, 
                                                    random_state=1)
# Create standardizer
standardizer = StandardScaler()

# Fit standardizer to training set
standardizer.fit(X_train)
# Apply to both training and test sets
X_train_std = standardizer.transform(X_train)
X_test_std = standardizer.transform(X_test)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12094594594594595, 'fraction_numerical': 0.019594594594594596, 'mean_word_length': 3.556923076923077, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 7, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '560106', 'license': 'MIT', 'n_tokens_mistral': 477, 'n_tokens_neox': 457, 'n_words': 106, 'path': 'Split_Data.ipynb', 'repo_name': 'sonukumarraj007/Deep-Learning-Machine-Learning-Stock', 'size': '1480'}