File size: 1,192 Bytes
e879b5c
803efd8
 
 
 
 
 
 
 
 
 
 
 
 
 
c842a8e
 
994c640
 
c842a8e
dfeeea4
994c640
dfeeea4
994c640
ee8e147
994c640
c842a8e
994c640
666bcf9
994c640
 
66e88b1
763e7bf
 
 
 
 
 
 
5fa734b
ee8e147
994c640
c842a8e
 
803efd8
 
c842a8e
 
803efd8
c842a8e
 
1dcf5d3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import gradio as gr
import hopsworks
import joblib
import pandas as pd
import numpy as np
import json
import time
from datetime import timedelta, datetime


from functions import *


project = hopsworks.login()
	

def air_quality(city):
    start_date = datetime.now() - timedelta(days=1)
    start_time = int(start_date.timestamp()) * 1000
    X = pd.read_csv('x.csv')

    #X = X.drop(columns=["date"]).fillna(0)

    X = X.drop(X.columns[0],axis=1)

    mr = project.get_model_registry()
    model = mr.get_model("gradient_boost_paris_model", version=1)
    model_dir = model.download()
    print(model_dir)
    model = joblib.load(model_dir + "/model.pkl")
	    
    preds = model.predict(X)
    #print(model.predict(X)[:7])

    predictions = ''
    for k in range(7):
        predictions += "Predicted AQI on  " + (datetime.now() + timedelta(days=k)).strftime('%Y-%m-%d') + ":      " + str(int(preds[k]))+"\n"
	        
        print(predictions)
    return predictions + model_dir



	
	
    
demo = gr.Interface(fn=air_quality, title="Air quality predictor",
description="Input a value to get next weeks AQI prediction for Paris", inputs="text", outputs="text")
	

	    
demo.launch()