Im a novice experimenting with machine learning. I saw this repo https://github.com/jbp261/Optimal-Classification-Model-of-BLE-RSSI-Dataset and wanted to replicate a similar experiment.
So I have 2 receivers and want to classify near which one the given values of Rssi are closest. I captured some training data and defined area 0(near beacon 1) and area 1(near beacon 2).
I build a model with keras (also tried with a RandomForest which works fine) but even when evaluating the base training data with an accuracy of 0.8 I get 50% wrong prediction.
batch_size = 100
#reading the input samples and separating the input from the outputs
dataframe = pd.read_csv("C:\aaa\Log.csv")
labels = dataframe.pop('result')
#creating the dataset from the data
ds = tf.data.Dataset.from_tensor_slices((dict(dataframe), labels))
ds = ds.batch(batch_size)
feature_columns = []
headers = dataframe.columns.tolist()
# numeric cols
for header in headers:
temp = feature_column.numeric_column(header)
#feature_columns.append(feature_column.bucketized_column(temp, boundaries=[-70, -60, -50, -40 , -30])) tried also this
feature_columns.append(temp)
feature_layer = tf.keras.layers.DenseFeatures(feature_columns)
model = tf.keras.Sequential([
feature_layer,
layers.Dense(128, activation='relu'),
layers.Dense(128, activation='relu'),
layers.Dense(2, activation='sigmoid')
])
model.compile(optimizer='adam',
loss='binary_crossentropy',
metrics=['accuracy'])
model.fit(ds, epochs=20)
test_ds = tf.data.Dataset.from_tensor_slices((dict(dataframe), labels))
test_ds = test_ds.batch(batch_size)
loss, accuracy = model.evaluate(test_ds)
print("Accuracy", accuracy)