I am trying to work on building a neural network model in Keras, with an input shape of X= (1,32) and Y= (1,16). The dataset is: you can download it from here.
I tried to build a predictor which can predict Y ( with an accuracy of 100%).
I built that code:
% the data
Data: url= "/content/drive/MyDrive/data.csv"
AllData=Data;
% Spent it
TrainData , TestData=train_test_split(AllData, train_size=0.8);
TrainData , ValidationData=train_test_split(TrainData, train_size=0.8);
X= XTrainData.values
Y= YTrainData.values
XX=XValidationData.values
YY=YValidationData.values
% library:
from keras.layers import Lambda, Input, Dense, Reshape, RepeatVector, Dropout
from keras.models import Model
from keras.datasets import mnist
from keras.losses import mse, binary_crossentropy
from keras.utils import plot_model
from keras import backend as K
from keras.constraints import unit_norm, max_norm
import tensorflow as tf
from scipy import stats
import pandas as pd
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
import argparse
import os
from sklearn.manifold import MDS
from sklearn.model_selection import StratifiedKFold
from sklearn.metrics import mean_squared_error, r2_score
from keras.layers import Input, Dense, Flatten, Lambda,Conv1D, BatchNormalization, MaxPooling1D, Activation
from keras.models import Model
import keras.backend as K
import numpy as np
input_shape_x = (32, )
input_shape_r = (16, )
intermediate_dim = 32
latent_dim = 32
# Encoder network
inputs_x = Input(shape=input_shape_x, name='encoder_input')
a = Dense(128, activation='tanh')(inputs_x)
a = Dense(64, activation='tanh')(a)
a = Dense(32, activation='tanh')(a)
EEE = Dense(16, activation='tanh')(a)
predictor = Model(inputs_x, EEE, name='vae_mlp')
predictor.compile(optimizer='adam', loss= 'mean_absolute_error')
# Train the model
history = predictor.fit(X, Y, epochs=30, batch_size=32,validation_data=(XX, YY), validation_split=0.0005)
# Save models and plot training/validation loss
predictor.save("BrmPred Third.h5")
When I calculate the accuracy I always find it equals to 0.28
I need accuracy 0.001 and the model can predict Y by 99%.