Spaces:
Running
Running
charlieoneill
commited on
Commit
•
5c8cf60
1
Parent(s):
d6eab4f
christine version control
Browse files
app.py
CHANGED
@@ -144,6 +144,7 @@ import networkx as nx
|
|
144 |
import plotly.graph_objs as go
|
145 |
from ast import literal_eval as make_tuple
|
146 |
import random
|
|
|
147 |
|
148 |
import os
|
149 |
print(os.getenv('MODEL_REPO_ID'))
|
@@ -766,13 +767,24 @@ def create_interface():
|
|
766 |
feature_matches = gr.CheckboxGroup(label="Matching Features", choices=[])
|
767 |
add_button = gr.Button("Add Selected Features")
|
768 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
769 |
def search_feature_labels(search_text):
|
770 |
if not search_text:
|
771 |
return gr.CheckboxGroup(choices=[])
|
772 |
matches = [f for f in subject_data[current_subject]['feature_analysis'] if search_text.lower() in f['label'].lower()]
|
|
|
|
|
|
|
773 |
matches = sorted(matches, key=lambda x: x['pearson_correlation'], reverse=True)
|
774 |
matches = [f"{f['label']} ({f['index']})" for f in matches]
|
775 |
-
|
776 |
return gr.CheckboxGroup(choices=matches[:10])
|
777 |
|
778 |
feature_search.change(search_feature_labels, inputs=[feature_search], outputs=[feature_matches])
|
@@ -899,13 +911,24 @@ def create_interface():
|
|
899 |
|
900 |
|
901 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
902 |
def search_feature_labels(search_text, current_subject):
|
903 |
if not search_text:
|
904 |
return gr.CheckboxGroup(choices=[])
|
905 |
matches = [f for f in subject_data[current_subject]['feature_analysis'] if search_text.lower() in f['label'].lower()]
|
|
|
|
|
|
|
906 |
matches = sorted(matches, key=lambda x: x['pearson_correlation'], reverse=True)
|
907 |
matches = [f"{f['label']} ({f['index']})" for f in matches]
|
908 |
-
|
909 |
return gr.CheckboxGroup(choices=matches[:10])
|
910 |
|
911 |
feature_search.change(search_feature_labels, inputs=[feature_search, subject], outputs=[feature_matches])
|
@@ -947,11 +970,25 @@ def create_interface():
|
|
947 |
|
948 |
# family_info = gr.Markdown()
|
949 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
950 |
def search_feature_families(search_text, current_subject):
|
951 |
family_analysis = subject_data[current_subject]['family_analysis']
|
952 |
if not search_text:
|
953 |
return gr.CheckboxGroup(choices=[])
|
954 |
matches = [family for family in family_analysis if search_text.lower() in family['superfeature'].lower()]
|
|
|
|
|
|
|
955 |
matches = sorted(matches, key=lambda x: x['family_pearson'], reverse=True)
|
956 |
matches = [family['superfeature'] for family in matches]
|
957 |
matches = list(dict.fromkeys(matches))
|
|
|
144 |
import plotly.graph_objs as go
|
145 |
from ast import literal_eval as make_tuple
|
146 |
import random
|
147 |
+
import math
|
148 |
|
149 |
import os
|
150 |
print(os.getenv('MODEL_REPO_ID'))
|
|
|
767 |
feature_matches = gr.CheckboxGroup(label="Matching Features", choices=[])
|
768 |
add_button = gr.Button("Add Selected Features")
|
769 |
|
770 |
+
# def search_feature_labels(search_text):
|
771 |
+
# if not search_text:
|
772 |
+
# return gr.CheckboxGroup(choices=[])
|
773 |
+
# matches = [f for f in subject_data[current_subject]['feature_analysis'] if search_text.lower() in f['label'].lower()]
|
774 |
+
# matches = sorted(matches, key=lambda x: x['pearson_correlation'], reverse=True)
|
775 |
+
# matches = [f"{f['label']} ({f['index']})" for f in matches]
|
776 |
+
|
777 |
+
# return gr.CheckboxGroup(choices=matches[:10])
|
778 |
+
|
779 |
def search_feature_labels(search_text):
|
780 |
if not search_text:
|
781 |
return gr.CheckboxGroup(choices=[])
|
782 |
matches = [f for f in subject_data[current_subject]['feature_analysis'] if search_text.lower() in f['label'].lower()]
|
783 |
+
for match in matches:
|
784 |
+
if math.isnan(match['pearson_correation']):
|
785 |
+
match['pearson_correlation'] = 0
|
786 |
matches = sorted(matches, key=lambda x: x['pearson_correlation'], reverse=True)
|
787 |
matches = [f"{f['label']} ({f['index']})" for f in matches]
|
|
|
788 |
return gr.CheckboxGroup(choices=matches[:10])
|
789 |
|
790 |
feature_search.change(search_feature_labels, inputs=[feature_search], outputs=[feature_matches])
|
|
|
911 |
|
912 |
|
913 |
|
914 |
+
# def search_feature_labels(search_text, current_subject):
|
915 |
+
# if not search_text:
|
916 |
+
# return gr.CheckboxGroup(choices=[])
|
917 |
+
# matches = [f for f in subject_data[current_subject]['feature_analysis'] if search_text.lower() in f['label'].lower()]
|
918 |
+
# matches = sorted(matches, key=lambda x: x['pearson_correlation'], reverse=True)
|
919 |
+
# matches = [f"{f['label']} ({f['index']})" for f in matches]
|
920 |
+
|
921 |
+
# return gr.CheckboxGroup(choices=matches[:10])
|
922 |
+
|
923 |
def search_feature_labels(search_text, current_subject):
|
924 |
if not search_text:
|
925 |
return gr.CheckboxGroup(choices=[])
|
926 |
matches = [f for f in subject_data[current_subject]['feature_analysis'] if search_text.lower() in f['label'].lower()]
|
927 |
+
for match in matches:
|
928 |
+
if math.isnan(match['pearson_correation']):
|
929 |
+
match['pearson_correlation'] = 0
|
930 |
matches = sorted(matches, key=lambda x: x['pearson_correlation'], reverse=True)
|
931 |
matches = [f"{f['label']} ({f['index']})" for f in matches]
|
|
|
932 |
return gr.CheckboxGroup(choices=matches[:10])
|
933 |
|
934 |
feature_search.change(search_feature_labels, inputs=[feature_search, subject], outputs=[feature_matches])
|
|
|
970 |
|
971 |
# family_info = gr.Markdown()
|
972 |
|
973 |
+
# def search_feature_families(search_text, current_subject):
|
974 |
+
# family_analysis = subject_data[current_subject]['family_analysis']
|
975 |
+
# if not search_text:
|
976 |
+
# return gr.CheckboxGroup(choices=[])
|
977 |
+
# matches = [family for family in family_analysis if search_text.lower() in family['superfeature'].lower()]
|
978 |
+
|
979 |
+
# matches = sorted(matches, key=lambda x: x['family_pearson'], reverse=True)
|
980 |
+
# matches = [family['superfeature'] for family in matches]
|
981 |
+
# matches = list(dict.fromkeys(matches))
|
982 |
+
# return gr.CheckboxGroup(choices=matches[:10]) # Limit to top 10 matches
|
983 |
+
|
984 |
def search_feature_families(search_text, current_subject):
|
985 |
family_analysis = subject_data[current_subject]['family_analysis']
|
986 |
if not search_text:
|
987 |
return gr.CheckboxGroup(choices=[])
|
988 |
matches = [family for family in family_analysis if search_text.lower() in family['superfeature'].lower()]
|
989 |
+
for family in matches:
|
990 |
+
if math.isnan(family['family_pearson']):
|
991 |
+
family['family_pearson'] = 0
|
992 |
matches = sorted(matches, key=lambda x: x['family_pearson'], reverse=True)
|
993 |
matches = [family['superfeature'] for family in matches]
|
994 |
matches = list(dict.fromkeys(matches))
|