Spaces:
Sleeping
Sleeping
Commit
路
45f07b7
1
Parent(s):
f36dfc5
Silohuette Score
Browse files
app.py
CHANGED
|
@@ -7,7 +7,7 @@ from bokeh.layouts import column
|
|
| 7 |
from bokeh.palettes import Reds9, Blues9, Oranges9, Purples9, Greys9, BuGn9, Greens9, RdYlGn11, linear_palette
|
| 8 |
from sklearn.decomposition import PCA
|
| 9 |
from sklearn.manifold import TSNE, trustworthiness
|
| 10 |
-
from sklearn.metrics import pairwise_distances
|
| 11 |
from sklearn.preprocessing import MinMaxScaler
|
| 12 |
from sklearn.pipeline import Pipeline
|
| 13 |
from sklearn.base import BaseEstimator, TransformerMixin
|
|
@@ -577,10 +577,12 @@ def compute_global_regression(df_combined, embedding_cols, tsne_params, df_f1, r
|
|
| 577 |
|
| 578 |
trust = None
|
| 579 |
cont = None
|
|
|
|
| 580 |
if reduction_method in ("t-SNE","PCA"):
|
| 581 |
X = df_combined[embedding_cols].values
|
| 582 |
trust = trustworthiness(X, reduced, n_neighbors=TSNE_NEIGHBOURS)
|
| 583 |
cont = compute_continuity(X, reduced, n_neighbors=TSNE_NEIGHBOURS)
|
|
|
|
| 584 |
|
| 585 |
dfs_reduced, unique_subsets = split_versions(df_combined, reduced)
|
| 586 |
|
|
@@ -655,7 +657,8 @@ def compute_global_regression(df_combined, embedding_cols, tsne_params, df_f1, r
|
|
| 655 |
"df_distances": df_distances,
|
| 656 |
"explained_variance": explained_variance,
|
| 657 |
"trustworthiness": trust,
|
| 658 |
-
"continuity": cont
|
|
|
|
| 659 |
}
|
| 660 |
|
| 661 |
if reduction_method == "PCA":
|
|
@@ -790,8 +793,9 @@ def run_model(model_name):
|
|
| 790 |
st.table(variance_df)
|
| 791 |
# elif reduction_method == "t-SNE":
|
| 792 |
st.subheader(f"{reduction_method} Quality Metrics")
|
| 793 |
-
st.write(f"Trustworthiness: {result['trustworthiness']:.
|
| 794 |
-
st.write(f"Continuity: {result['continuity']:.
|
|
|
|
| 795 |
|
| 796 |
# # Mostrar los plots de loadings si se us贸 PCA (para el conjunto combinado)
|
| 797 |
# if reduction_method == "PCA" and result.get("pca_model") is not None:
|
|
|
|
| 7 |
from bokeh.palettes import Reds9, Blues9, Oranges9, Purples9, Greys9, BuGn9, Greens9, RdYlGn11, linear_palette
|
| 8 |
from sklearn.decomposition import PCA
|
| 9 |
from sklearn.manifold import TSNE, trustworthiness
|
| 10 |
+
from sklearn.metrics import pairwise_distances, silhouette_score
|
| 11 |
from sklearn.preprocessing import MinMaxScaler
|
| 12 |
from sklearn.pipeline import Pipeline
|
| 13 |
from sklearn.base import BaseEstimator, TransformerMixin
|
|
|
|
| 577 |
|
| 578 |
trust = None
|
| 579 |
cont = None
|
| 580 |
+
silhouette = None
|
| 581 |
if reduction_method in ("t-SNE","PCA"):
|
| 582 |
X = df_combined[embedding_cols].values
|
| 583 |
trust = trustworthiness(X, reduced, n_neighbors=TSNE_NEIGHBOURS)
|
| 584 |
cont = compute_continuity(X, reduced, n_neighbors=TSNE_NEIGHBOURS)
|
| 585 |
+
silhouette = silhouette_score(X, df_combined['label'])
|
| 586 |
|
| 587 |
dfs_reduced, unique_subsets = split_versions(df_combined, reduced)
|
| 588 |
|
|
|
|
| 657 |
"df_distances": df_distances,
|
| 658 |
"explained_variance": explained_variance,
|
| 659 |
"trustworthiness": trust,
|
| 660 |
+
"continuity": cont,
|
| 661 |
+
"silhouette": silhouette
|
| 662 |
}
|
| 663 |
|
| 664 |
if reduction_method == "PCA":
|
|
|
|
| 793 |
st.table(variance_df)
|
| 794 |
# elif reduction_method == "t-SNE":
|
| 795 |
st.subheader(f"{reduction_method} Quality Metrics")
|
| 796 |
+
st.write(f"Trustworthiness: {result['trustworthiness']:.2f}")
|
| 797 |
+
st.write(f"Continuity: {result['continuity']:.2f}")
|
| 798 |
+
st.write(f"Silhouette Score: {result['silhouette']:.2f}")
|
| 799 |
|
| 800 |
# # Mostrar los plots de loadings si se us贸 PCA (para el conjunto combinado)
|
| 801 |
# if reduction_method == "PCA" and result.get("pca_model") is not None:
|