# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

import numpy as np
import pandas as pd
from sklearn.discriminant_analysis import LinearDiscriminantAnalysis as LDA
from sklearn.metrics import classification_report, confusion_matrix

Smarket = pd.read_csv("/Users/arpanganguli/Documents/Finance/ISLR/Datasets/Smarket.csv", index_col = 'SlNo')

Smarket.head()

from sklearn.model_selection import train_test_split

X = np.array(Smarket[['Lag1', 'Lag2']])
y = np.array(Smarket['Direction'])
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2016, random_state=101)

ldafit = LDA()
ldafit.fit(X_train, y_train)

ldafit.priors_

ldafit.means_

ldafit.coef_

ldapred = ldafit.predict(X_test)

print(confusion_matrix(y_test, ldapred))

print(classification_report(y_test, ldapred))

# **The precision is intuitively the ability of the classifier not to label as positive a sample that is negative. Therefore,
# this model is able to correctly classify 57% of the test data (which I believe is great given the vagaries of the stock 
# market!!**

StarcoderdataJupyterScriptsDedupFiltered