2021-06-22 19:02:44 +02:00
|
|
|
import numpy as np
|
|
|
|
#from neural_network import *
|
|
|
|
from numpy import loadtxt
|
|
|
|
import pandas as pd
|
|
|
|
from sklearn.model_selection import train_test_split
|
|
|
|
import tensorflow as tf
|
|
|
|
from tensorflow.keras.layers import Dense, Dropout
|
|
|
|
|
|
|
|
products = ['glass', 'mixed', 'metal', 'paper']
|
|
|
|
n_products = len(products)
|
|
|
|
data = pd.read_csv("X_test.csv")
|
|
|
|
dff = data.loc[:, data.columns != 'Unnamed: 0']
|
|
|
|
def b():
|
|
|
|
a = dff.sample()
|
|
|
|
pred(a)
|
|
|
|
|
2021-06-22 19:15:39 +02:00
|
|
|
model = tf.keras.models.load_model('./saved_model')
|
2021-06-22 19:02:44 +02:00
|
|
|
|
|
|
|
|
|
|
|
def pred(a):
|
|
|
|
print(a)
|
|
|
|
prediction_proba = model.predict(np.array(a))
|
|
|
|
prediction = np.argmax(prediction_proba)
|
|
|
|
text_representation = products[prediction]
|
|
|
|
print(text_representation)
|
|
|
|
print(prediction)
|
|
|
|
return prediction
|