Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -4,14 +4,28 @@ import streamlit as st
|
|
4 |
from PIL import Image
|
5 |
import numpy as np
|
6 |
import pandas as pd
|
7 |
-
import ast
|
8 |
|
9 |
# Load Sequential Model
|
10 |
model_cnn = load_model('car_model.h5')
|
11 |
|
12 |
# Load DataFrame
|
13 |
-
|
14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
|
16 |
def calculate_cicilan(predicted_label):
|
17 |
# Get car info based on predicted_label
|
@@ -22,12 +36,9 @@ def calculate_cicilan(predicted_label):
|
|
22 |
cicilan_per_bulan = harga_mobil_avg / 60 # 5 tahun (60 bulan)
|
23 |
|
24 |
# Find the matching gaji range based on cicilan_per_bulan
|
25 |
-
df_income_info['rentang_gaji'] = df_income_info['rentang_gaji'].apply(lambda x: ast.literal_eval(x))
|
26 |
matching_income = df_income_info[
|
27 |
-
(cicilan_per_bulan / 0.3 >= df_income_info['rentang_gaji'].apply(lambda x:
|
28 |
-
(cicilan_per_bulan / 0.3 <= df_income_info['rentang_gaji'].apply(lambda x:
|
29 |
-
|
30 |
-
|
31 |
|
32 |
if not matching_income.empty:
|
33 |
rentang_usia = matching_income['rentang_usia'].iloc[0]
|
|
|
4 |
from PIL import Image
|
5 |
import numpy as np
|
6 |
import pandas as pd
|
|
|
7 |
|
8 |
# Load Sequential Model
|
9 |
model_cnn = load_model('car_model.h5')
|
10 |
|
11 |
# Load DataFrame
|
12 |
+
income_data = {
|
13 |
+
'pekerjaan': ["Staff - Fresh Graduate", "Asisten Manajer", "Manajer", "General Manajer", "Kepala Divisi atau Direksi"],
|
14 |
+
'rentang_usia': [(21, 25), (26, 29), (29, 35), (36, 42), (42, 100)],
|
15 |
+
'rentang_gaji': [(2000000, 4000000), (5000000, 8000000), (10000000, 15000000), (20000000, 30000000), (50000000, 100000000)]
|
16 |
+
}
|
17 |
+
|
18 |
+
data = {
|
19 |
+
'predicted_label': [0, 1, 2, 3],
|
20 |
+
'jenis_mobil': ["Alphard", "Innova 2015-2022", "Innova Zennix", "New Veloz"],
|
21 |
+
'merek_mobil': ["Toyota", "Toyota", "Toyota", "Toyota"],
|
22 |
+
'harga_mobil_min': [1356100000, 215000000, 425000000, 288000000],
|
23 |
+
'harga_mobil_max': [1950000000, 480000000, 610000000, 350000000]}
|
24 |
+
|
25 |
+
# Create DataFrame
|
26 |
+
df_car_info = pd.DataFrame(data)
|
27 |
+
df_income_info = pd.DataFrame(income_data)
|
28 |
+
|
29 |
|
30 |
def calculate_cicilan(predicted_label):
|
31 |
# Get car info based on predicted_label
|
|
|
36 |
cicilan_per_bulan = harga_mobil_avg / 60 # 5 tahun (60 bulan)
|
37 |
|
38 |
# Find the matching gaji range based on cicilan_per_bulan
|
|
|
39 |
matching_income = df_income_info[
|
40 |
+
(cicilan_per_bulan / 0.3 >= df_income_info['rentang_gaji'].apply(lambda x: x[0])) &
|
41 |
+
(cicilan_per_bulan / 0.3 <= df_income_info['rentang_gaji'].apply(lambda x: x[1]))]
|
|
|
|
|
42 |
|
43 |
if not matching_income.empty:
|
44 |
rentang_usia = matching_income['rentang_usia'].iloc[0]
|