<jupyter_start><jupyter_text>PCA usig pca library<jupyter_code>df = pd.read_csv("pca_gsp.csv")
df.head()
df.describe()
plt.figure(figsize=(10,6))
correlation = df.corr()
sns.heatmap(correlation, annot= True)
df.columns
features = ['Ag', 'Mining', 'Constr', 'Manuf', 'Manuf_nd', 'Transp','Comm', 'Energy', 'TradeW', 'TradeR', 'RE', 'Services', 'Govt']
x = df.loc[:, features].values
states = df.State
from pca import pca
model = pca(n_components=5,normalize=True)
result = model.fit_transform(x)
##result
loadings = result['loadings']
loadings
scores=result['PC']
scores['labels'] = states
scores.head()
model.plot(figsize=(8,6))
plt.show()<jupyter_output><empty_output><jupyter_text>PCA biplots displays both PC scores and PC loadings<jupyter_code>model.biplot(n_feat=5,legend=False,figsize=(15,12),y=states,label=True)
plt.show()
model.scatter(legend=False,y=states)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1806020066889632, 'fraction_numerical': 0.012263099219620958, 'mean_word_length': 9.32183908045977, 'pattern_counts': {'":': 0, '<': 9, '<?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': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '435391', 'license': 'MIT', 'n_tokens_mistral': 368, 'n_tokens_neox': 348, 'n_words': 60, 'path': 'PCA.ipynb', 'repo_name': 'Sauravjha21/Python-For-Research', 'size': '897'}