Improving Accuracy Of A Tensorflow Neural Network- Python
This is a continuation of my first question: Receiving random cost output on tensorflow regression- python I am using a multi-layered perceptron ANN to predict the Phyla of bacteri
Solution 1:
I figured it out! In order to improve accuracy, it is necessary to break the train and test batches into random samples, else the network will not process necessary data and will fail. I have implemented this by rewriting the data formatting section as such:
df = pd.read_csv('/Users/zach/desktop/export.csv')
data_ = df.drop(['ID','Species'], axis=1)
n_classes = data_["Phylum"].nunique()
dim = 18
learning_rate = 0.0001
display_step = 10
n_hidden_1 = 2000
n_hidden_2 = 1500
n_hidden_3 = 1000
n_hidden_4 = 500
X = tf.placeholder(tf.float32, [None, dim])
train_set = data_.sample(frac=0.75) #THIS ADDITION SPLITS THE DATA RANDOMLY AND TAKE 75% FOR TRAINING
test_set = data_.loc[~data_.index.isin(train_set.index)] #THIS TAKES THE REMAINING DATA FOR TESTING
train_size = train_set.size
inputY_test = pd.get_dummies(test_set['Phylum'])
inputY_train = pd.get_dummies(train_set['Phylum'])
train_X = train_set.iloc[:train_size, :-1].as_matrix()
train_X = pd.DataFrame(data=train_X)
train_X = train_X.fillna(value=0).as_matrix()
train_Y = inputY_train.as_matrix()
train_Y = pd.DataFrame(data=train_Y)
train_Y = train_Y.fillna(value=0).as_matrix()
test_X = test_set.iloc[:, :-1].as_matrix()
test_X = pd.DataFrame(data=test_X)
test_X = test_X.fillna(value=0).as_matrix()
test_Y = inputY_test.as_matrix()
test_Y = pd.DataFrame(data=test_Y)
test_Y = test_Y.fillna(value=0).as_matrix()
With these edits a simple run of 50 epochs, taking about 2 minutes, predicted the correct result with an accuracy of 91.4%
Post a Comment for "Improving Accuracy Of A Tensorflow Neural Network- Python"