-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.py
38 lines (38 loc) · 1.94 KB
/
test.py
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
import pandas as pd
import tensorflow as tf
import numpy as np
from tensorflow.keras.models import load_model
# Example Data user from X_test (index 0) with 43 column
# Column :
# Air Energi Protein Lemak Abu Karbohidrat Serat Total Gula Total Kalsium (Ca)
# Besi (Fe) Magnesium (Mg) Fosfor (P) Kalium (K) Natrium (Na) Seng (Zn) Tembaga (Cu)
# Mangan (Mn) Selenium (Se) Vitamin C Tiamina (B1) Riboflavin (B2)
# Niasin Pantotenat (B5) Vitamin B6 Folat Total (B9) Kolina Vitamin B12 Vitamin A IU
# Vitamin A RAE Retinol a-karoten b-karoten b-kriptosantin Likopen Zeaksantin + Lutein Vitamin E
# Vitamin D Vitamin D IU Vitamin K Lemak Jenuh Lemak Tunggal Lemak Ganda Kolesterol
data_user_1 = np.array([[ 0, 6.2920e+01, 0, 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 0, 0]])
data_user_2 = np.array([[ 3.8746e+02, 6.2920e+01, 4.0100e+00, 3.2300e+00, 5.2000e-01,
4.3300e+00, -5.0000e-01, 3.9300e+00, 1.2344e+02, 7.3000e-01,
1.2450e+01, 8.4280e+01, 1.3436e+02, 1.1796e+02, 4.4000e-01,
9.2000e-01, -3.5000e-01, 4.0400e+00, -4.9000e-01, -1.0000e-01,
9.4000e-01, -4.0000e-02, -3.4000e-01, 3.7000e-01, 5.2900e+00,
1.5190e+01, 2.8000e-01, 1.6486e+02, 4.6100e+01, 4.6860e+01,
-7.9000e-01, 7.3100e+00, -3.1000e-01, -3.4000e-01, 2.4000e-01,
-3.9000e-01, 3.7000e-01, 5.1150e+01, 1.0600e+00, 1.0800e+00,
1.6000e-01, -6.4000e-01, 1.1850e+01]])
dataset=pd.read_csv('List_Label.csv')
model = load_model(r'Models\food_model_1.h5')
y_pred = model.predict(data_user_1)
top_5 = np.argsort(y_pred.flatten())[-5:]
selected_rows = dataset.loc[dataset['label'].isin(top_5), ['name', 'label']]
selected_rows.sort_values(by='label',ascending=True,inplace=True)
# Print or use the selected rows
print(selected_rows.drop_duplicates(subset=['label']))