Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -161,6 +161,9 @@ else:
|
|
161 |
if data['Domestic Violence'] == "No":
|
162 |
shelters = shelters[(shelters['Domestic Violence'] == "No")]
|
163 |
|
|
|
|
|
|
|
164 |
# calculate distances between zipcodes
|
165 |
if data['Zip Code'] != "Unsure":
|
166 |
geocoding_api_key = os.environ['OpenWeather_API_KEY']
|
@@ -174,17 +177,18 @@ else:
|
|
174 |
|
175 |
max = max(distances) if (max(distances) != 0) else 1
|
176 |
shelters['zipcode_score'] = [d / max for d in distances]
|
|
|
177 |
|
178 |
# get urgency scores
|
179 |
urgency_scores = shelters.apply(lambda row: get_urgency_score(data['Urgency'], row['Urgency']), axis=1).tolist()
|
180 |
shelters['urgency_score'] = urgency_scores
|
|
|
181 |
|
182 |
# get duration scores
|
183 |
duration_scores = shelters.apply(lambda row: get_duration_score(data['Duration'], row['Duration']), axis=1).tolist()
|
184 |
shelters['duration_score'] = duration_scores
|
|
|
185 |
|
186 |
-
|
187 |
-
|
188 |
# services
|
189 |
if data['Needs'] != "":
|
190 |
OpenAI_API_KEY = os.environ["OPENAI_API_KEY"]
|
@@ -193,8 +197,16 @@ else:
|
|
193 |
services_scores = [s / 10 for s in services_scores]
|
194 |
|
195 |
shelters['services_score'] = services_scores
|
|
|
196 |
|
197 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
198 |
|
199 |
shelters = [
|
200 |
{"title": "Shelter 1", "description": "This is the 1st shelter",},
|
|
|
161 |
if data['Domestic Violence'] == "No":
|
162 |
shelters = shelters[(shelters['Domestic Violence'] == "No")]
|
163 |
|
164 |
+
# keep track of which scores are calculated
|
165 |
+
scores = []
|
166 |
+
|
167 |
# calculate distances between zipcodes
|
168 |
if data['Zip Code'] != "Unsure":
|
169 |
geocoding_api_key = os.environ['OpenWeather_API_KEY']
|
|
|
177 |
|
178 |
max = max(distances) if (max(distances) != 0) else 1
|
179 |
shelters['zipcode_score'] = [d / max for d in distances]
|
180 |
+
scores.append('zipcode_score')
|
181 |
|
182 |
# get urgency scores
|
183 |
urgency_scores = shelters.apply(lambda row: get_urgency_score(data['Urgency'], row['Urgency']), axis=1).tolist()
|
184 |
shelters['urgency_score'] = urgency_scores
|
185 |
+
scores.append('urgency_score')
|
186 |
|
187 |
# get duration scores
|
188 |
duration_scores = shelters.apply(lambda row: get_duration_score(data['Duration'], row['Duration']), axis=1).tolist()
|
189 |
shelters['duration_score'] = duration_scores
|
190 |
+
scores.append('duration_score')
|
191 |
|
|
|
|
|
192 |
# services
|
193 |
if data['Needs'] != "":
|
194 |
OpenAI_API_KEY = os.environ["OPENAI_API_KEY"]
|
|
|
197 |
services_scores = [s / 10 for s in services_scores]
|
198 |
|
199 |
shelters['services_score'] = services_scores
|
200 |
+
scores.append('services_score')
|
201 |
|
202 |
+
# calcualte cumulative score
|
203 |
+
total_scores = pd.Series()
|
204 |
+
for s in scores:
|
205 |
+
total_scores += s
|
206 |
+
total_scores = [s/4 for s in total_scores]
|
207 |
+
shelters['total_score'] = total_scores
|
208 |
+
|
209 |
+
|
210 |
|
211 |
shelters = [
|
212 |
{"title": "Shelter 1", "description": "This is the 1st shelter",},
|