<jupyter_start><jupyter_text>Imports<jupyter_code>from time import time
from sklearn import datasets
from sklearn.model_selection import train_test_split

from sklearn.discriminant_analysis import LinearDiscriminantAnalysis as LDA
from sklearn.tree import DecisionTreeClassifier #Performance checking of LDA<jupyter_output><empty_output><jupyter_text>Loading Iris dataset<jupyter_code>data = datasets.load_iris()
X = data.data
y = data.target
X.shape
y.shape
X_train, X_test, y_train, y_test = train_test_split(X, y, train_size=0.80, test_size=0.20, random_state=1)<jupyter_output><empty_output><jupyter_text>LDA and performace<jupyter_code>t0 = time()
tree = DecisionTreeClassifier(criterion="entropy")
tree.fit(X_train, y_train)
accuracy = tree.score(X_test, y_test)
print("Done: TIME TAKEN-> %0.3fs"%(time() - t0))
print("ACCURACY: ", accuracy*100)
t0 = time()
lda = LDA(n_components=2)
lda.fit(X_train, y_train)
accuracy = lda.score(X_test, y_test)
print("Done: TIME TAKEN-> %0.3fs"%(time() - t0))
print("ACCURACY: ", accuracy*100)
t0 = time()
lda = LDA(n_components=2)
lda.fit(X_train, y_train)
tree.fit(lda.transform(X_train), y_train)
accuracy = tree.score(lda.transform(X_test), y_test)
print("Done: TIME TAKEN-> %0.3fs"%(time() - t0))
print("ACCURACY: ", accuracy*100)<jupyter_output>Done: TIME TAKEN-> 0.005s
ACCURACY:  96.66666666666667
{'fraction_non_alphanumeric': 0.13734224201930215, 'fraction_numerical': 0.03711952487008166, 'mean_word_length': 7.868421052631579, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 1, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '588294', 'license': 'MIT', 'n_tokens_mistral': 566, 'n_tokens_neox': 535, 'n_words': 100, 'path': 'Assignment02/Assignment 02 LDA.ipynb', 'repo_name': 'tusharsaxena250/AIML_Course', 'size': '1347'}