<jupyter_start><jupyter_text>Categorical and Continuous Data Categorical data: data contain a finite number of categories or distinct groups. Categorical data might not have a logical order. For example, categorical predictors include gender, material type, and payment method. On the other hand, categorical have strings or labels. Continuous data: are numeric variables that have an infinite number of values between any two values. A continuous variable can be numeric or date/time. For example, the length of a part or the date and time a payment is received.<jupyter_code>import numpy as np
import matplotlib.pyplot as plt
import pandas as pd

import warnings
warnings.filterwarnings("ignore")

# fix_yahoo_finance is used to fetch data 
import fix_yahoo_finance as yf
yf.pdr_override()
# input
symbol = 'AMD'
start = '2014-01-01'
end = '2019-01-01'

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

# View Columns
dataset.head()
# Create Data
dataset['Open_Close'] = (dataset['Open'] - dataset['Adj Close'])/dataset['Open']
dataset['High_Low'] = (dataset['High'] - dataset['Low'])/dataset['Low']
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.head()
# Create Labels string
dataset['Increase_Decrease_L'] = np.where(dataset['Volume'].shift(-1) > dataset['Volume'],'Increase','Decrease')
dataset['Buy_Sell_on_Open_L'] = np.where(dataset['Open'].shift(-1) > dataset['Open'],'Buy','Sell')
dataset['Buy_Sell_L'] = np.where(dataset['Adj Close'].shift(-1) > dataset['Adj Close'],'Buy','Sell')
dataset.head()
dataset.info()
# separating the features and labels

data_feat = dataset.drop(columns=["Buy_Sell"],axis=1)
data_label = dataset["Buy_Sell"]
# first just take a look at all the columns
list(data_feat.columns)
categorical_columns = [col for col in data_feat.columns if len(data_feat[col].unique())==2 or data_feat[col].dtype=='O']
continuous_columns = [col for col in data_feat.columns if len(data_feat[col].unique())>2 and (data_feat[col].dtype=='int64' or data_feat[col].dtype=='float64')]
print("Categorical Variables:")
print("categorical columns : ", categorical_columns)
print('-'*50)
print("Continuous Variables:")
print("continuous columns : ", continuous_columns)<jupyter_output>Categorical Variables:
categorical columns :  ['Increase_Decrease', 'Buy_Sell_on_Open', 'Increase_Decrease_L', 'Buy_Sell_on_Open_L', 'Buy_Sell_L']
--------------------------------------------------
Continuous Variables:
continuous columns :  ['Open', 'High', 'Low', 'Close', 'Adj Close', 'Open_Close', 'High_Low', 'Returns']
{'fraction_non_alphanumeric': 0.1653737658674189, 'fraction_numerical': 0.01304654442877292, 'mean_word_length': 6.237244897959184, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '135984', 'license': 'MIT', 'n_tokens_mistral': 935, 'n_tokens_neox': 883, 'n_words': 238, 'path': 'Categorical_Continuous.ipynb', 'repo_name': 'sonukumarraj007/Deep-Learning-Machine-Learning-Stock', 'size': '2836'}