2
$\begingroup$

I have a data sample of RSSI value from three different devices and based on the RSSI sample, it should tell from which location the data sample is arrived. Below are the sample data set,

 device_1  device_2  device_3  location
 -45       -56       -78       drawing_room
 -48       -51       -82       drawing_room
 -41       -59       -73       drawing_room
 -71       -59       -59       conference
 -69       -60       -65       conference
 -73       -60       -52       conference
 -33       -68       -64       kitchen
 -32       -66       -63       kitchen
 -37       -67       -61       kitchen
 -63       -48       -48       lab
 -62       -48       -46       lab
 -59       -48       -54       lab

I will have "n" No.of data samples for "m" No.of location. The actual data set can be find here.

I want to predict "location" from the d1 d2 d3. Based on what parameters (i.e., correlation matrix or visualization), the machine learning algorithm can be chosen for the given data set?

The visualization chart for the considered data set is enter image description here

From the visualization chart, Does it mean only the column "device_1" and "device_2" has a good separation among the location compared to other columns?

Note: If required, the data samples can be considered as positive.

$\endgroup$
  • 1
    $\begingroup$ Could you state more clearly exactly what you want to predict, and what features you want to use to predict it? I.e. do you want to predict location from d1 d2 d3? $\endgroup$ – Sheridan Grant Aug 28 at 6:52
  • $\begingroup$ Yes, I want to predict location from d1 d2 d3 features $\endgroup$ – Mahamutha M Aug 28 at 7:04
  • $\begingroup$ You can train a neural network to classify the location based on three numeric features d1, d2 and d3. Also, we can normalize the features. $\endgroup$ – Shubham Panchal Aug 28 at 7:32
  • 2
    $\begingroup$ By looking at the features I would guess that a simpler method might be sufficient. The plot of device1-device3 is almost linearly seperable, thus linear seperators should get a reasonable level of correct predictions. You stated in another comment that you tried SVM and Random Forest, so maybe you need to tune the hyperparameters there. $\endgroup$ – Eulenfuchswiesel Aug 28 at 10:09
  • $\begingroup$ @Eulenfuchswiesel, Thank you for your comment. Let me try with the hyperparameters. $\endgroup$ – Mahamutha M Aug 28 at 10:29
1
$\begingroup$

I used a simple Neural Network with 3 Inputs - 8 hidden layers - 3 Outputs (Labels) with k-fold crossvalidation in keras for your data set.

import pandas as pd
from keras.models import Sequential
from keras.layers import Dense
from keras.wrappers.scikit_learn import KerasClassifier
from keras.utils import np_utils
from sklearn.model_selection import cross_val_score
from sklearn.model_selection import KFold
from sklearn.preprocessing import LabelEncoder, scale
from sklearn.pipeline import Pipeline

path = r"User\train.csv"
data = pd.read_csv(path)

data.location.value_counts()
dataset = data.values

x = dataset[:,0:3]
x_scaled = scale(x)
y = dataset[:,3]


encoder = LabelEncoder()
encoder.fit(y)
encoded_Y = encoder.transform(y)

dummy_y = np_utils.to_categorical(encoded_Y)

def model():
    model = Sequential()
    model.add(Dense(8, input_dim=3, activation='relu'))
    model.add(Dense(3, activation='softmax'))

    model.compile(loss='categorical_crossentropy', optimizer='adam', metrics=['accuracy'])

    return model



estimator = KerasClassifier(build_fn=model, epochs=200, batch_size=5, verbose=0)
kfold = KFold(n_splits=10, shuffle=True)

results = cross_val_score(estimator, x_scaled, dummy_y, cv=kfold)
print("Model Prediction: %.2f%% (%.2f%%)" % (results.mean()*100, results.std()*100))

The used Model can categorize around 94% of the data correctly. Maybe this helps for the start.

Out:
Prediction: 93.95% (3.13%)

In data science and statistics in general you have to try and train several models to see which suits your dataset best (model benchmarking). In the end it is often a trade-off between computational costs and accuracy.

$\endgroup$
  • $\begingroup$ Thank you for your suggestion. Let me evaluate this with the real time data set for prediction and check how the performance is. I have tried with SVM & Random Forest classification algorithm, 40 to 50% of the test samples are predicting the adjacent location. Thats why I thought to get some suggestion here. $\endgroup$ – Mahamutha M Aug 28 at 9:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.