I am trying understand Artificial Intelligence Neural Network and I am self-learner. Hope anyone would help me in understanding on how to solve this problem
If this post should be posted here. Please comment instead of degrading the post. Appreciate for this as well.
I have a question that I am totally confused about how to solve it. I encountered this online but was unable to understand how to solve it. I have added the question below. Hope you can provide some help.
The data set contains 4 observations for 4 input variables (Temp, Pres, Flow, and Process) and an output variable (Rejects). The first column "No" is simply an identifier. The table below reproduces the first 4 observations:
No | Temp | Pres | Flow | Process | Rejects |
---|---|---|---|---|---|
1 | 53.39 | 10.52 | 4.82 | 0 | 1.88 |
2 | 46.23 | 15.13 | 5.31 | 0 | 2.13 |
3 | 42.85 | 18.79 | 3.59 | 0 | 2.66 |
4 | 53.09 | 18.33 | 3.67 | 0 | 2.03 |
Train a back-propagation neural network on approximately 80% of the observations, randomly selected. Test the trained network using the remaining 20% observations.
Question:
I would really appreciate your help.
Firstly, the dataset is insanely small. However, this is the way you would approach this kind of dataset, assuming there is much more data.
import pandas as pd
import tensorflow as tf
from tensorflow.keras import Sequential
from tensorflow.keras.layers import Dropout, Dense, Flatten
data = {
'No.': [1, 2, 3, 4],
'Temp': [53.39, 46.23, 42.85, 53.09],
'Pres': [10.52, 15.13, 18.79, 18.33],
'Process': [0, 0, 0, 0],
'Rejects': [1.88, 2.13, 2.66, 2.03]
}
df = pd.DataFrame(data)
df = df.drop(['No.'], axis=1)
features = df.drop(['Rejects'], axis=1)
labels = df['Rejects']
model = Sequential()
model.add(Dense(1000, activation='relu', input_shape=(features.shape[1],1)))
model.add(Dropout(0.2))
model.add(Dense(250, activation='relu'))
model.add(Dropout(0.2))
model.add(Dense(50, activation='relu'))
model.add(Dropout(0.2))
model.add(Dense(1, activation='relu'))
model.compile(optimizer='adam', loss='mean_squared_error', metrics=['mse','mae','mape'])
model.fit(features, labels, epochs=10)
model.evaluate(features,labels)
The results are not good, but that is only due to the quantity of data.
1/1 [==============================] - 0s 316ms/step - loss: 2.4341 - mse: 2.4341 - mae: 1.4419 - mape: 67.6981