BIPLOTI run the below code but the legend is not in the correct order. Also, I have 2 target variables. It would be valuable if I added both variables with two legends.
from sklearn.decomposition import PCA
from sklearn.preprocessing import StandardScaler
import bioinfokit
from bioinfokit.analys import get_data
from bioinfokit.visuz import cluster
import matplotlib.pyplot as plt
import pandas as pd
# load iris dataset
df= pd.read_csv (r'PCA.csv')
df.head(2)
X = df.iloc[:,0:14]
target = df[ 'IRI'].to_numpy()
X.head(2)
print(X.head)
X_st = StandardScaler().fit_transform(X)
pca_out = PCA().fit(X_st)
# component loadings
loadings = pca_out.components_
loadings
print(loadings)
# get eigenvalues (variance explained by each PC)
pca_out.explained_variance_
# get biplot
pca_scores = PCA().fit_transform(X_st)
cluster.biplot(cscore=pca_scores, loadings=loadings, labels=X.columns.values, var1=round(pca_out.explained_variance_ratio_[0]*100, 2),
var2=round(pca_out.explained_variance_ratio_[1]*100, 2))
bioinfokit.visuz.cluster.biplot(cscore=pca_scores,
loadings=pca_out.components_,
labels=X.columns.values,
var1=round(pca_out.explained_variance_ratio_[0]*100, 2), var2=round(pca_out.explained_variance_ratio_[1]*100, 2), show=True, colordot= 'b', axlabelfontsize= 13,
axlabelfontname= 'Times New Roman', dotsize= 20, legendpos= 'upper right', arrowcolor='red', colorlist= target, r=300, markerdot= 'o',
valphadot= 1,valphaarrow= 0.5, arrowlinewidth= 0.5, centerlines= True, datapoints= True, dim=(8,6) )