Spaces:
Runtime error
Runtime error
add matplotlib
Browse files- app.py +17 -5
- requirements.txt +1 -0
app.py
CHANGED
@@ -16,7 +16,6 @@ import hashlib
|
|
16 |
import gradio as gr
|
17 |
import scann
|
18 |
|
19 |
-
|
20 |
df=pd.read_csv("/home/user/app/Dubai_translated_best_2500.csv",sep=",",header=0)
|
21 |
df=df.drop_duplicates()
|
22 |
df=df.dropna()
|
@@ -148,7 +147,7 @@ cp_callback = tf.keras.callbacks.ModelCheckpoint(
|
|
148 |
save_weights_only=True,
|
149 |
save_freq=2)
|
150 |
|
151 |
-
model.fit(cached_train, callbacks=[cp_callback],epochs=
|
152 |
|
153 |
index=df["code"].map(lambda x: [model.movie_model(tf.constant(x))])
|
154 |
|
@@ -160,14 +159,27 @@ searcher = scann.scann_ops_pybind.builder(np.array(indice), 10, "dot_product").t
|
|
160 |
num_leaves=1500, num_leaves_to_search=500, training_sample_size=df.shape[0]).score_brute_force(
|
161 |
2, quantize=True).build()
|
162 |
|
|
|
|
|
163 |
def predict(text):
|
164 |
campos=str(text).lower()
|
165 |
query=np.sum([model.user_model(tf.constant(campos.split()[i])) for i in range(0,len(campos.split()))],axis=0)
|
166 |
neighbors, distances = searcher.search_batched([query])
|
167 |
xx = df.iloc[neighbors[0],:].nome_vaga
|
168 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
169 |
|
170 |
demo = gr.Interface(fn=predict, inputs=gr.inputs.Textbox(label='CANDIDATE COMPETENCES - Click *Clear* before adding new input'), \
|
171 |
-
outputs=gr.outputs.Textbox(label='SUGGESTED VACANCIES'),\
|
|
|
172 |
css='div {margin-left: auto; margin-right: auto; width: 100%;\
|
173 |
-
background-image: url("https://drive.google.com/uc?export=view&id=1KNnISAUcvh2Pt08f-EJZJYCIgkrKw3PI"); repeat 0 0;}')
|
|
|
|
16 |
import gradio as gr
|
17 |
import scann
|
18 |
|
|
|
19 |
df=pd.read_csv("/home/user/app/Dubai_translated_best_2500.csv",sep=",",header=0)
|
20 |
df=df.drop_duplicates()
|
21 |
df=df.dropna()
|
|
|
147 |
save_weights_only=True,
|
148 |
save_freq=2)
|
149 |
|
150 |
+
model.fit(cached_train, callbacks=[cp_callback],epochs=2)
|
151 |
|
152 |
index=df["code"].map(lambda x: [model.movie_model(tf.constant(x))])
|
153 |
|
|
|
159 |
num_leaves=1500, num_leaves_to_search=500, training_sample_size=df.shape[0]).score_brute_force(
|
160 |
2, quantize=True).build()
|
161 |
|
162 |
+
import matplotlib.pyplot as plt
|
163 |
+
|
164 |
def predict(text):
|
165 |
campos=str(text).lower()
|
166 |
query=np.sum([model.user_model(tf.constant(campos.split()[i])) for i in range(0,len(campos.split()))],axis=0)
|
167 |
neighbors, distances = searcher.search_batched([query])
|
168 |
xx = df.iloc[neighbors[0],:].nome_vaga
|
169 |
+
fig = plt.figure(figsize=(14,9))
|
170 |
+
plt.bar(list(xx),distances[0]*0.8*10)
|
171 |
+
plt.title('Degree of match')
|
172 |
+
plt.xlabel('Labels')
|
173 |
+
plt.xticks(rotation=270)
|
174 |
+
|
175 |
+
plt.ylabel('Distances')
|
176 |
+
for x, y in zip(list(range(0,10)),distances[0]*0.8*10):
|
177 |
+
plt.text(x, y, y, ha='center', va='bottom', fontsize=12, color='black')
|
178 |
+
return xx, fig
|
179 |
|
180 |
demo = gr.Interface(fn=predict, inputs=gr.inputs.Textbox(label='CANDIDATE COMPETENCES - Click *Clear* before adding new input'), \
|
181 |
+
outputs=[gr.outputs.Textbox(label='SUGGESTED VACANCIES'),\
|
182 |
+
gr.Plot()],\
|
183 |
css='div {margin-left: auto; margin-right: auto; width: 100%;\
|
184 |
+
background-image: url("https://drive.google.com/uc?export=view&id=1KNnISAUcvh2Pt08f-EJZJYCIgkrKw3PI"); repeat 0 0;}')\
|
185 |
+
.launch(share=False)
|
requirements.txt
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
nltk==3.6.5
|
2 |
pandas==1.3.4
|
3 |
numpy==1.22.4
|
|
|
4 |
unidecode==1.2.0
|
5 |
tensorflow==2.9.1
|
6 |
scann==1.2.7
|
|
|
1 |
nltk==3.6.5
|
2 |
pandas==1.3.4
|
3 |
numpy==1.22.4
|
4 |
+
matplotlib==3.4.3
|
5 |
unidecode==1.2.0
|
6 |
tensorflow==2.9.1
|
7 |
scann==1.2.7
|