AI_PROJEKT_2021/neural_network2.py

27 lines
731 B
Python
Raw Permalink Normal View History

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)
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