Spaces:
Running
Running
Delete app.py
Browse files
app.py
DELETED
|
@@ -1,59 +0,0 @@
|
|
| 1 |
-
import streamlit as st
|
| 2 |
-
import time
|
| 3 |
-
import json
|
| 4 |
-
from gensim.models import Word2Vec
|
| 5 |
-
import pandas as pd
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
query = st.text_input("Enter a word")
|
| 9 |
-
# query = input ("Enter your keyword(s):")
|
| 10 |
-
|
| 11 |
-
if query:
|
| 12 |
-
model = Word2Vec.load("pubmed_model_clotting") # you can continue training with the loaded model!
|
| 13 |
-
words = list(model.wv.key_to_index)
|
| 14 |
-
X = model.wv[model.wv.key_to_index]
|
| 15 |
-
model2 = model.wv[query]
|
| 16 |
-
df = pd.DataFrame(X)
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
# def findRelationships(query, df):
|
| 20 |
-
table = model.wv.most_similar_cosmul(query, topn=10000)
|
| 21 |
-
table = (pd.DataFrame(table))
|
| 22 |
-
table.index.name = 'Rank'
|
| 23 |
-
table.columns = ['Word', 'SIMILARITY']
|
| 24 |
-
print()
|
| 25 |
-
print("Similarity to " + str(query))
|
| 26 |
-
pd.set_option('display.max_rows', None)
|
| 27 |
-
print(table.head(100))
|
| 28 |
-
table.head(10).to_csv("clotting_sim1.csv", index=True)
|
| 29 |
-
st.header(f"Similar Words to {query}")
|
| 30 |
-
st.write(table.head(50))
|
| 31 |
-
#
|
| 32 |
-
print()
|
| 33 |
-
print("Human genes similar to " + str(query))
|
| 34 |
-
df1 = table
|
| 35 |
-
df2 = pd.read_csv('Human_Genes.csv')
|
| 36 |
-
m = df1.Word.isin(df2.symbol)
|
| 37 |
-
df1 = df1[m]
|
| 38 |
-
df1.rename(columns={'Word': 'Human Gene'}, inplace=True)
|
| 39 |
-
print(df1.head(10))
|
| 40 |
-
print()
|
| 41 |
-
df1.head(10).to_csv("clotting_sim2.csv", index=True, header=False)
|
| 42 |
-
time.sleep(2)
|
| 43 |
-
st.header(f"Similar Genes to {query}")
|
| 44 |
-
st.write(df1.head(50))
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
# findRelationships(query, df)
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
# model = gensim.models.KeyedVectors.load_word2vec_format('pubmed_model_clotting', binary=True)
|
| 56 |
-
# similar_words = model.most_similar(word)
|
| 57 |
-
# output = json.dumps({"word": word, "similar_words": similar_words})
|
| 58 |
-
# st.write(output)
|
| 59 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|