# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

import keras
import pandas as pd
import numpy as np
import h5py
import os
from sklearn.metrics import confusion_matrix,classification_report

# model = keras.models.load_model('model_lstm2')
keras.backend.clear_session()
model = keras.models.load_model('model_lstm2')

# +
X = []
y = []
emosi = ['kaget','marah','santai','senang']

maindirs = 'Feature_extract'
dirs = os.listdir(maindirs)
emosi = ['kaget','marah','santai','senang']
df = pd.read_csv(maindirs+"/"+"tes_extracted.csv")
label = pd.get_dummies(df['EMOSI'])
d_t = df.drop('EMOSI',axis=1)

data_len = int(len(d_t))

for i in range (0,data_len):
    temp = d_t.iloc[i]
    temp_list = temp.values.tolist()
    X.append(temp_list)
for j in range(0,data_len):
    temp1 = label.iloc[j]
    temp1_list = temp1.values.tolist()
    y.append(temp1_list)
    
X = np.array(X)
y = np.array(y)
for i in range(1,160):
    length = 160
    num_train = 0
#     index = np.random.randint(0,length, size=length)
    train_X = X[index[0:num_train]]
    train_Y = y[index[0:num_train]]
    test_X = X[index[num_train:]]
    test_Y = y[index[num_train:]]
#     test_X = X[num_train:]
#     test_Y = y[num_train:]
    train_X = np.reshape(train_X, (train_X.shape[0],1,train_X.shape[1]))
    test_X = np.reshape(test_X, (test_X.shape[0],1,test_X.shape[1]))

    y_pred = model.predict(test_X)
#     print(float(y_pred[i][0]))
    print(emosi[(y_pred[0][0])])
#     matrix = confusion_matrix(test_Y.argmax(axis=1), y_pred.argmax(axis=1))
#     print('kaget,marah,santai,senang')
#     print(matrix)
#     print(classification_report(test_Y.argmax(axis=1), y_pred.argmax(axis=1), digits=3,target_names=emosi))

StarcoderdataJupyterScriptsDedupFiltered