gui-sparim commited on
Commit
204827e
1 Parent(s): 89487a8

Upload 6 files

Browse files
app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+ import gradio as gr
3
+ import boxes
4
+ import convert
5
+
6
+ bloco = gr.Blocks()
7
+
8
+ with bloco:
9
+ with gr.Tabs():
10
+ with gr.TabItem(boxes.title):
11
+ gr.Markdown(boxes.description)
12
+ inputs = boxes.load_inputs()
13
+ text_button = gr.Button("Calcular")
14
+ outputs = gr.TextArea(lines=1, label=boxes.output_label)
15
+ text_button.click(boxes.execute, inputs=inputs, outputs=outputs)
16
+ with gr.TabItem(convert.title):
17
+ gr.Markdown(convert.description)
18
+ inputs = convert.load_inputs()
19
+ text_button = gr.Button("Calcular")
20
+ outputs = gr.TextArea(lines=1, label=convert.output_label)
21
+ text_button.click(convert.execute, inputs=inputs, outputs=outputs)
22
+
23
+ bloco.launch()
boxes.py ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import pandas as pd
3
+ import numpy as np
4
+ import xgboost as xgb
5
+ import joblib
6
+
7
+ def execute(FONTE, IDADE, DF, X, Y, ATOTAL, ANO_2019, ANO_2020, ANO_2021, ANO_2022):
8
+ df = pd.DataFrame.from_dict({'FONTE': [FONTE],
9
+ 'IDADE': [IDADE],
10
+ 'DF': [DF],
11
+ 'X': [X],
12
+ 'Y': [Y],
13
+ 'ATOTAL': np.log([ATOTAL]),
14
+ 'ANO_2019': [ANO_2019],
15
+ 'ANO_2020': [ANO_2020],
16
+ 'ANO_2021': [ANO_2021],
17
+ 'ANO_2022': [ANO_2022],
18
+ })
19
+
20
+ input_scaler = joblib.load("dados/boxes/input_scaler_boxes_2022.save")
21
+ df = input_scaler.transform(df)
22
+ cols = ['FONTE', 'IDADE', 'DF', 'X', 'Y', 'ATOTAL', 'ANO_2019', 'ANO_2020', 'ANO_2021', 'ANO_2022']
23
+ aval = pd.DataFrame(df, columns = cols)
24
+ df = xgb.DMatrix(aval)
25
+ loaded_model = xgb.Booster()
26
+ loaded_model.load_model("dados/boxes/boxes_2020_2021_2022_2023_lean.model")
27
+ pred = loaded_model.predict(df)
28
+ output_scaler = joblib.load("dados/boxes/output_scaler_boxes_2022.save")
29
+ pred = output_scaler.inverse_transform(np.array(pred).reshape(-1,1))
30
+ pred = np.exp(pred).tolist()
31
+ return f"""R${round(pred[0][0], -2)}"""
32
+
33
+
34
+ def load_inputs():
35
+ FONTE = gr.inputs.Number(default = 0, label='Fonte: 0 - Transação | 1 - Oferta')
36
+ ATOTAL = gr.inputs.Number(default = 15., label='Área Total')
37
+ DF = gr.inputs.Number(default = 1, label='Divisão Fiscal (1, 2 ou 3)')
38
+ IDADE = gr.inputs.Number(default = 1, label='Idade do imóvel (Ano Base: 2022)')
39
+ ANO_2019 = gr.inputs.Number(default = 0, label='Ano 2019')
40
+ ANO_2020 = gr.inputs.Number(default = 0, label='Ano 2020')
41
+ ANO_2021 = gr.inputs.Number(default = 0, label='Ano 2021')
42
+ ANO_2022 = gr.inputs.Number(default = 1, label='Ano 2022')
43
+ # gr.Dropdown(["ran", "swam", "ate", "slept"], value=["swam", "slept"], multiselect=True)
44
+ Y = gr.inputs.Number(default = 1.672718e+06, label='Latitude (SIRGAS 2000)')
45
+ X = gr.inputs.Number(default = 282122.159663, label='Longitude (SIRGAS 2000)')
46
+ return [FONTE, IDADE, DF, X, Y, ATOTAL, ANO_2019, ANO_2020, ANO_2021, ANO_2022]
47
+
48
+ output_label = "Valor do imóvel (R$)"
49
+
50
+ title = 'Venda - Boxes de estacionamento'
51
+
52
+ description = '7.173 dados de Janeiro de 2019 a Outubro de 2022'
convert.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import numpy as np
3
+
4
+ def execute(lat, long):
5
+ def TM_Y():
6
+ return (5000000) + (0.999995) * ( ((6378137)*(((1-(((2*(1/298.257222101)) - ((1/298.257222101)**2))/4)-((3*((2*(1/298.257222101)) - ((1/298.257222101)**2))**2)/64)-((5*((2*(1/298.257222101)) - ((1/298.257222101)**2))**3)/256))*(np.radians(lat))) - (((3/8)*(((2*(1/298.257222101)) - ((1/298.257222101)**2))+((((2*(1/298.257222101)) - ((1/298.257222101)**2))**2)/4)+((15*((2*(1/298.257222101)) - ((1/298.257222101)**2))**3)/128)))*np.sin(2*(np.radians(lat)))) + (((15/256)*((2*(1/298.257222101) - (1/298.257222101)**2)**2 + ((3*(2*(1/298.257222101) - (1/298.257222101)**2)**3)/4)))*np.sin(4*(np.radians(lat)))) - ((35*((2*(1/298.257222101) - (1/298.257222101)**2))**3 / 3072)*np.sin(6*(np.radians(lat)))))) -
7
+ (0) +
8
+ (((np.radians(long)-(-0.890117918517108))**2 / 2)*(6378137/(np.sqrt(1-(2*(1/298.257222101) - (1/298.257222101)**2)*(np.sin(np.radians(lat)))**2)))*np.sin(np.radians(lat))*np.cos(np.radians(lat))) +
9
+ (((np.radians(long)-(-0.890117918517108))**4 / 24) * (6378137/(np.sqrt(1-(2*(1/298.257222101) - (1/298.257222101)**2)*(np.sin(np.radians(lat)))**2))) * np.sin(np.radians(lat)) * (np.cos(np.radians(lat)))**3 * (4*((6378137/(np.sqrt(1-(2*(1/298.257222101) - (1/298.257222101)**2)*(np.sin(np.radians(lat)))**2)))/(((6378137*(1-(2*(1/298.257222101) - (1/298.257222101)**2)))/(1-(2*(1/298.257222101) - (1/298.257222101)**2)*(np.sin(np.radians(lat)))**2)**(3/2))))**2 + ((6378137/(np.sqrt(1-(2*(1/298.257222101) - (1/298.257222101)**2)*(np.sin(np.radians(lat)))**2)))/(((6378137*(1-(2*(1/298.257222101) - (1/298.257222101)**2)))/(1-(2*(1/298.257222101) - (1/298.257222101)**2)*(np.sin(np.radians(lat)))**2)**(3/2)))) - (np.tan(np.radians(lat)))**2)) +
10
+ (((np.radians(long)-(-0.890117918517108))**6 / 720) * (6378137/(np.sqrt(1-(2*(1/298.257222101) - (1/298.257222101)**2)*(np.sin(np.radians(lat)))**2))) * np.sin(np.radians(lat)) * (np.cos(np.radians(lat)))**5 * ((8*((6378137/(np.sqrt(1-(2*(1/298.257222101) - (1/298.257222101)**2)*(np.sin(np.radians(lat)))**2)))/(((6378137*(1-(2*(1/298.257222101) - (1/298.257222101)**2)))/(1-(2*(1/298.257222101) - (1/298.257222101)**2)*(np.sin(np.radians(lat)))**2)**(3/2))))**4 * (11-24*(np.tan(np.radians(lat)))**2)) - (28*((6378137/(np.sqrt(1-(2*(1/298.257222101) - (1/298.257222101)**2)*(np.sin(np.radians(lat)))**2)))/(((6378137*(1-(2*(1/298.257222101) - (1/298.257222101)**2)))/(1-(2*(1/298.257222101) - (1/298.257222101)**2)*(np.sin(np.radians(lat)))**2)**(3/2))))**3 * (1-6*(np.tan(np.radians(lat)))**2)) + (((6378137/(np.sqrt(1-(2*(1/298.257222101) - (1/298.257222101)**2)*(np.sin(np.radians(lat)))**2)))/(((6378137*(1-(2*(1/298.257222101) - (1/298.257222101)**2)))/(1-(2*(1/298.257222101) - (1/298.257222101)**2)*(np.sin(np.radians(lat)))**2)**(3/2))))**2 * (1-32*(np.tan(np.radians(lat)))**2)) - (((6378137/(np.sqrt(1-(2*(1/298.257222101) - (1/298.257222101)**2)*(np.sin(np.radians(lat)))**2)))/(((6378137*(1-(2*(1/298.257222101) - (1/298.257222101)**2)))/(1-(2*(1/298.257222101) - (1/298.257222101)**2)*(np.sin(np.radians(lat)))**2)**(3/2)))) * (2*(np.tan(np.radians(lat)))**2)) + (np.tan(np.radians(lat)))**4)) +
11
+ (((np.radians(long)-(-0.890117918517108))**8 / 40320) * (6378137/(np.sqrt(1-(2*(1/298.257222101) - (1/298.257222101)**2)*(np.sin(np.radians(lat)))**2))) * np.sin(np.radians(lat)) * (np.cos(np.radians(lat)))**7 * (1385 - 3111*(np.tan(np.radians(lat)))**2 + 543*(np.tan(np.radians(lat)))**4 - (np.tan(np.radians(lat)))**6)))
12
+
13
+
14
+ def TM_X():
15
+ return 300000 + 0.999995 * (6378137/(np.sqrt(1-(2*(1/298.257222101) - (1/298.257222101)**2)*(np.sin(np.radians(lat)))**2))) * (np.radians(long)-(np.radians(-51.))) * np.cos(np.radians(lat)) * (1 + (((np.radians(long)-(np.radians(-51.)))**2 / 6) * (np.cos(np.radians(lat)))**2 * (((6378137/(np.sqrt(1-(2*(1/298.257222101) - (1/298.257222101)**2)*(np.sin(np.radians(lat)))**2)))/(((6378137*(1-(2*(1/298.257222101) - (1/298.257222101)**2)))/(1-(2*(1/298.257222101) - (1/298.257222101)**2)*(np.sin(np.radians(lat)))**2)**(3/2)))) - (np.tan(np.radians(lat)))**2)) + (((np.radians(long)-(np.radians(-51.)))**4 / 120) * (np.cos(np.radians(lat)))**4 * (4*((6378137/(np.sqrt(1-(2*(1/298.257222101) - (1/298.257222101)**2)*(np.sin(np.radians(lat)))**2)))/(((6378137*(1-(2*(1/298.257222101) - (1/298.257222101)**2)))/(1-(2*(1/298.257222101) - (1/298.257222101)**2)*(np.sin(np.radians(lat)))**2)**(3/2))))**3 * (1 - 6*(np.tan(np.radians(lat)))**2) + ((6378137/(np.sqrt(1-(2*(1/298.257222101) - (1/298.257222101)**2)*(np.sin(np.radians(lat)))**2)))/(((6378137*(1-(2*(1/298.257222101) - (1/298.257222101)**2)))/(1-(2*(1/298.257222101) - (1/298.257222101)**2)*(np.sin(np.radians(lat)))**2)**(3/2))))**2 * (1+8*(np.tan(np.radians(lat)))**2) - ((6378137/(np.sqrt(1-(2*(1/298.257222101) - (1/298.257222101)**2)*(np.sin(np.radians(lat)))**2)))/(((6378137*(1-(2*(1/298.257222101) - (1/298.257222101)**2)))/(1-(2*(1/298.257222101) - (1/298.257222101)**2)*(np.sin(np.radians(lat)))**2)**(3/2))))*2*(np.tan(np.radians(lat)))**2 + (np.tan(np.radians(lat)))**4)) + (((np.radians(long)-(np.radians(-51.)))**6 / 5040) * (np.cos(np.radians(lat)))**6 * (61 - 479*(np.tan(np.radians(lat)))**2 + 179*(np.tan(np.radians(lat)))**4 - (np.tan(np.radians(lat)))**6)))
16
+
17
+ return TM_X(), TM_Y()
18
+
19
+ def load_inputs():
20
+ lat = gr.inputs.Number(default = -30.027300489258348, label='Latitude (WGS84)')
21
+ long = gr.inputs.Number(default = -51.22889665713565, label='Longitude (WGS84)')
22
+ return [lat, long]
23
+
24
+ output_label = "Coordenadas Convertidas"
25
+ title = 'Conversor de Coordenadas'
26
+ description = 'WGS84 para TM-POA'
dados/boxes/boxes_2020_2021_2022_2023_lean.model ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:849da858a86e4ec5d48783e50f2271faa6ae3cfca296ac516b9e41fdf3e6b4e8
3
+ size 2100940
dados/boxes/input_scaler_boxes_2022.save ADDED
Binary file (967 Bytes). View file
 
dados/boxes/output_scaler_boxes_2022.save ADDED
Binary file (607 Bytes). View file