<jupyter_start><jupyter_text>Glass Dataset's<jupyter_code>import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
data = pd.read_csv('Dataset/glass.csv')
data
# spliting data into ddependent and independent

x = data.iloc[:,0:9]
y = data.iloc[:,9]

x.info()
# splitting trainnig dataset

from sklearn.model_selection import train_test_split
x_train, x_test, y_train, y_test = train_test_split (x , y , test_size = .30, random_state = 1)

print(x_train)
print(x_test)
print(y_train)
print(y_test)
# applying Logistic Regression

from sklearn.linear_model import LogisticRegression
lr = LogisticRegression ()
lr.fit (x_train, y_train)
# # Using Min-MAx
# from sklearn.preprocessing import MinMaxScaler      # range 
# mms = MinMaxScaler()
# x_train_norm = mms.fit_transform (x_train) #fit and transform
# x_test_norm = mms.transform (x_test) # only transform
# Using Scaller
from sklearn.preprocessing import StandardScaler
independent_scalar = StandardScaler()
x_train_norm = independent_scalar.fit_transform (x_train) #fit and transform
x_test_norm = independent_scalar.transform (x_test) # only transform
# Using PCA
from sklearn.decomposition import PCA

pc = PCA(n_components=3)
X_pca=pc.fit_transform(x_train_norm)
print(pc.explained_variance_ratio_)
X_pca
df = pd.DataFrame(X_pca,columns = ['RI','Na','Mg'])
#print(df)
#print(df.iloc[:,0])

plt.plot(df)

# plt.scatter(df.iloc[:,0], df.iloc[:,1], marker='o'); 

plt.xlabel('RI')
plt.ylabel('Na')
plt.show()
# accuracy check
predict = lr.predict (x_test_norm)

from sklearn.metrics import accuracy_score
print(accuracy_score(y_test, predict))

from sklearn.metrics import confusion_matrix
cm = confusion_matrix (y_test, predict)

print(cm)
# normal Way ---> 70.7% 
# using MinMAx ---> 47.6% 
# using Scaller ---> 58.4%
# using PCA ---> 58.4%<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1233695652173913, 'fraction_numerical': 0.011956521739130435, 'mean_word_length': 5.818518518518519, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '100592', 'license': 'MIT', 'n_tokens_mistral': 693, 'n_tokens_neox': 678, 'n_words': 155, 'path': 'Lec 14 Claasification Weekend Assignment/Glass.ipynb', 'repo_name': 'AkashKumarSingh11032001/IBM-Artificial-Intelligence-and-Machine-Learning-By-IBM-Watson', 'size': '1840'}