1
$\begingroup$
  1. 1) Could it be useful to use RNN for classification problem?(e.g. to distinguish which action is taken: car is going, walking, digging, nothing).
  2. If 1 question is positive, how should RNN structure look like?

I have dataset of 4 actions, many examples for each action, each example includes 124 samples. So my X_train, X_test are arrays of float(400000, 124, 1); y_train, y_test are arrays of int(0 or 1 or 2 or 3 depends on action).

My data preprocessing:

X_train, X_test, y_train, y_test = np.array(X_train), np.array(X_test), np.array(y_train), np.array(y_test)
X_train = np.reshape(X_train, (X_train.shape[0], X_train.shape[1], 1)) 
X_test = np.reshape(X_test, (X_test.shape[0], X_test.shape[1], 1))

My structure:

regressor = Sequential()
regressor.add(LSTM(units=55, return_sequences=True, input_shape=(X_train.shape[1], 1)))
regressor.add(Dropout(0.2)) 
regressor.add(LSTM(units=50))
regressor.add(Dropout(0.2))
regressor.add(Dense(4,activation='softmax'))

regressor.compile(optimizer='adam', loss='sparse_categorical_crossentropy')
regressor.fit(X_train, y_train, epochs=5, batch_size=32)
y_pred = regressor.predict(X_test)
$\endgroup$
4
  • $\begingroup$ If I understand correctly, you are asking if RNN can be used for classification? Any reason why you are thinking in this way? $\endgroup$
    – Nischal Hp
    Feb 17 '20 at 10:33
  • $\begingroup$ yes. i have 124 samples(values) for one example of specific action. i have many examples of each action; and correlation of these 124 values is similar among examples of specific action but is different comparing to example of another action. So i'd love my network could extract this correlation and thanks to this be good at predicting a final result. In my opinion RNN should be great in finding this correlation(possibly i'm wrong). @NischalHp $\endgroup$
    – CapJS
    Feb 17 '20 at 11:00
  • $\begingroup$ What is the type of data you are working with? Its textual or numeric? How many features quantify as 1 sample? $\endgroup$
    – Nischal Hp
    Feb 17 '20 at 12:23
  • $\begingroup$ Type is float64; 124 features for one example. @NischalHp $\endgroup$
    – CapJS
    Feb 17 '20 at 13:02
0
$\begingroup$

@CapJS,

Instead of going ahead with an RNN, which helps you model the dependencies and relationship between your content, I would suggest you to take a look at 1D convolution networks to achieve the classification of activity.

There is a nice post talking about something similar : https://machinelearningmastery.com/cnn-models-for-human-activity-recognition-time-series-classification/

With 1D convolution, you are by design gaining better processing performance and given that you have just 124 samples per activity, you do not need a deep layered network as the data size is still quite small.

Given the data size, I would also suggest you to go ahead with something as simple as logistic regression, random forest approach. Hope this helps.

$\endgroup$
2
  • $\begingroup$ i misunderstood you. In this way i have only 1 feature(e.g. (300k, 124, 1). So, there's no sense to use cnn in this situation, i think. But anyway i've tried to use this type with different kernel sizes(3x3, 2x2 and 1x1) with maxpooling but the best accuracy that i managed to achive was 80 percent. So, simple ANN was a little better where i managed to get 81 percent. Any more ideas how could i get better accuracy?) @NischalHp $\endgroup$
    – CapJS
    Feb 24 '20 at 8:44
  • $\begingroup$ I think, the more important thing to look at in classification is to look at f1 score, precision and recall. Based on the outcome you want to reach i.e higher precision vs higher recall, you can finetune your network accordingly. $\endgroup$
    – Nischal Hp
    Feb 27 '20 at 10:16

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.