Update app.py
Browse files
app.py
CHANGED
|
@@ -7,8 +7,6 @@ import pandas as pd
|
|
| 7 |
|
| 8 |
from utils import compute_features
|
| 9 |
|
| 10 |
-
dataset = pd.read_csv("cleaned_df_noindex.csv")
|
| 11 |
-
df_amenities = pd.read_csv("df_amenities.csv")
|
| 12 |
|
| 13 |
class NegBinomialModel(nn.Module):
|
| 14 |
def __init__(self, in_features):
|
|
@@ -32,14 +30,16 @@ def negbinom_loss(y, mu, alpha):
|
|
| 32 |
)
|
| 33 |
return -torch.mean(log_prob)
|
| 34 |
|
| 35 |
-
model = NegBinomialModel(
|
| 36 |
model.load_state_dict(torch.load("model_weights.pt"))
|
| 37 |
model.eval()
|
| 38 |
|
| 39 |
-
# ======== Prediction Function ========
|
| 40 |
def predict_score(lat, lon):
|
| 41 |
# Convert input to tensor
|
| 42 |
-
inputs = torch.tensor([[lat, lon]], dtype=torch.float32)
|
|
|
|
|
|
|
|
|
|
| 43 |
|
| 44 |
# Get model output
|
| 45 |
with torch.no_grad():
|
|
|
|
| 7 |
|
| 8 |
from utils import compute_features
|
| 9 |
|
|
|
|
|
|
|
| 10 |
|
| 11 |
class NegBinomialModel(nn.Module):
|
| 12 |
def __init__(self, in_features):
|
|
|
|
| 30 |
)
|
| 31 |
return -torch.mean(log_prob)
|
| 32 |
|
| 33 |
+
model = NegBinomialModel(17)
|
| 34 |
model.load_state_dict(torch.load("model_weights.pt"))
|
| 35 |
model.eval()
|
| 36 |
|
|
|
|
| 37 |
def predict_score(lat, lon):
|
| 38 |
# Convert input to tensor
|
| 39 |
+
# inputs = torch.tensor([[lat, lon]], dtype=torch.float32)
|
| 40 |
+
inputs = compute_features((lat,lon))
|
| 41 |
+
|
| 42 |
+
inputs = torch.tensor([lat,lon] + list(inputs.values))
|
| 43 |
|
| 44 |
# Get model output
|
| 45 |
with torch.no_grad():
|