sequence-classification | Scikit-learn compatible sequence classifier | Machine Learning library
kandi X-RAY | sequence-classification Summary
kandi X-RAY | sequence-classification Summary
Scikit-learn compatible sequence classifier
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Fit the model .
- Builds the model .
- Check input X and y .
- Serializes a net to a temporary file .
- Deserialize a network from bytes .
- Delete the given file .
sequence-classification Key Features
sequence-classification Examples and Code Snippets
Community Discussions
Trending Discussions on sequence-classification
QUESTION
I am working with NFL play positional tracking data where there are multiple rows per play. Such I want to organize my data as such:
x_train = [[a1,b1,c1,...],[a2,b2,c2,...],...,[an,bn,cn,...]] y_train = [y1,y2,...,yn]
Where x_train holds tracking data from a play and y_train holds the outcome of the play.
I saw examples of using imdb data for sentiment analysis with a Keras LSTM model and wanted to try the same with my tracking data. But, I am having issues formatting my x_train.
...ANSWER
Answered 2020-Nov-25 at 22:10I have worked with the Keras LSTM layer in the past, and this seems like a very interesting application of it. I would like to help, but there are many things that go into formatting data for the LSTM layer and before getting it to work properly I would like to clarify the goal of this application.
The positional play data, is that where players are located on the field?
The play outcome data, is this the results of the play i.e. yards gained/lost, passing/running play, etc.?
What are the values you hope to get out of this? (Categorical or numerical)
EDIT/Answer:
Use the .append() method on a list to add to it.
QUESTION
I am trying to understand how to correctly feed data into my keras model to classify multivariate time series data into three classes using a LSTM neural network.
I looked at different resources already - mainly these three excellent blog posts by Jason Brownlee post1, post2, post3), other SO questions and different papers, but none of the information given there exactly fits my problem case, and I was not able to figure out if my data preprocessing / feeding it into the model is correct, so I guessed I might get some help if I specify my exact conditions here.
What I am trying to do is classify multivariate time series data, which in its original form is structured as follows:
I have 200 samples
One sample is one csv file.
A sample can have 1 to 50 features (i.e. the csv file has 1 to 50 columns).
Each feature has its value "tracked" over a fixed amount of time steps, let's say 100 (i.e. each csv file has exactly 100 rows).
Each csv file has one of three classes ("good", "too small", "too big")
So what my current status looks like is the following:
I have a numpy array "samples" with the following structure:
...ANSWER
Answered 2018-Sep-28 at 02:41I believe the input shape for Keras should be:
input_shape=(number_of_samples, nb_time_steps, max_nb_features).
And most often nb_time_steps = 1
P.S.: I tried solving a very similar problem for an internship position (but my results turned out to be wrong). You may take a look here: https://github.com/AbbasHub/Deep_Learning_LSTM/blob/master/2018-09-22_Multivariate_LSTM.ipynb (see if you can spot my mistake!)
QUESTION
I'm throwing myself into machine learning, and wish to use Keras for a university project that's time-critical. I realise it would be best to learn individual concepts and building blocks, but it's important that this is done soon.
I'm working with someone who has some experience and interest in machine learning, but we cannot seem to get further than this. The below code was adapted from GitHub code mentioned in a guide in Machine Learning Mastery.
For context, I've got data from multiple physical sensors (where each sensor is a column), with each sample from those sensors represented by one row. I wish to use machine learning to determine who the sensors were tracking at any given time. I'm trying to allocate approximately 80% of the rows to training and 20% to testing, and am creating my own "y" set of data (with the first 521,549 rows being from one participant, and the remainder from another). My data (training and test) has a total of 1,019,802 rows, and 16 columns (all populated), but the number of columns can be reduced if need be.
I would love to know the following:
- What does this error mean in the context of what I'm trying to achieve, and how can I change my code to avoid it?
- Is the below code suitable for what I'm trying to achieve?
- Does this code represent any specific fundamental flaw in my understanding of what machine learning (generally or specifically) is designed to achieve?
Below is the Python code I'm trying to run to make use of machine learning:
...ANSWER
Answered 2018-Jul-03 at 12:35There are some more tutorials on Machine Learning Mastery for what you want to accomplish https://machinelearningmastery.com/convert-time-series-supervised-learning-problem-python/ https://machinelearningmastery.com/time-series-prediction-lstm-recurrent-neural-networks-python-keras/
And I'll give my own quick explanation of what you probably want to do.
Right now it looks like you are using the exact same data for the X and y inputs into your model. The y inputs are the labels which in your case is "who the sensors were tracking". So in the binary case of having 2 possible people it is set to 0 for the first person and 1 for the second person.
The sigmoid activation on the final layer will output a number between 0 and 1. If the number is bellow 0.5 then it is predicting that the sensor is tracking person 0 and if it above 0.5 then it is predicting person 1. This will be represented in the accuracy score.
You will probably not want to use an embedding layer, its possible that you might but I would drop it to start with. Normalize your data though before feeding it into the net to improve training. Scikit-Learn has good tools for this if you want a quick solution. http://scikit-learn.org/stable/modules/preprocessing.html
When working with time series data you often want to feed in a window of time points rather than a single point. If you send your time series to Keras model.fit() then it will use a single point as input.
In order to have a time window as input you need to reorganize each example in the data set to be a whole window, or you can use a generator if that will take up to much memory. This is described in the Machine Learning Mastery pages that I linked. Keras has a generator that you can use called TimeseriesGenerator
QUESTION
I am trying to understand how LSTM is used to classify text sentences (word sequences) consists of pre-trained word embeddings. I am reading through some posts about lstm and I am confused about the detailed procedure:
IMDB classification using LSTM on keras: https://machinelearningmastery.com/sequence-classification-lstm-recurrent-neural-networks-python-keras/ Colah's explanation on LSTM: http://colah.github.io/posts/2015-08-Understanding-LSTMs/
Say for example, I want to use lstm to classify movie reviews, each review has fixed length of 500 words. And I am using pre-trained word embeddings (from fasttext) that gives 100-dimension vector for each word. What will be the dimensions of Xt to feed into the LSTM? And how is the LSTM trained? If each Xt is a 100-dimension vector represent one word in a review, do I feed each word in a review to a LSTM at a time? What will LSTM do in each epoch? I am really confused...
...ANSWER
Answered 2018-May-18 at 21:02You are confusing some terms, let's try to clarify what is going on step by step:
- The data in your case will of shape (samples, 500) which means we have some number of reviews, each review is maximum 500 words encoded as integers.
- Then the
Embedding
layer goeswords[index]
for every word in every sample giving a tensor (samples, 500, 100) if your embedding size is 100. - Now here is the confusing bit, when we say
LSTM(100)
it means a layer that runs a single LSTM cell (one like in Colah's diagram) over every word that has an output size of 100. Let me try that again, you create a single LSTM cell that transform the input into a 100 size output (hidden size) and the layer runs the same cell over the words. - Now we obtain (samples, 100) because the same LSTM processes every review of 500 words and return the final output which is of size 100. If for example we passed
return_sequences=True
then every hidden output, h-1, h, h+1 in the diagram would be returned so we would have obtained a shape (samples, 500, 100). - Finally, we pass the (samples, 100) to a
Dense
layer to make the prediction which gives (samples, 1) so a prediction for every review in the batch.
Take away lesson is that the LSTM
layer wraps around a LSTMCell and runs it over every timestep for you so you don't have to write the loop operations yourself.
QUESTION
I'm currently using a Naive Bayes algorithm to do my text classification.
My end goal is to be able to highlight parts of a big text document if the algorithm has decided the sentence belonged to a category.
Naive Bayes results are good, but I would like to train a NN for this problem, so I've followed this tutorial: http://machinelearningmastery.com/sequence-classification-lstm-recurrent-neural-networks-python-keras/ to build my LSTM network on Keras.
All these notions are quite difficult for me to understand right now, so excuse me if you see some really stupid things in my code.
1/ Preparation of the training dataI have 155 sentences of different sizes that have been tagged to a label.
All these tagged sentences are in a training.csv file:
...ANSWER
Answered 2017-Jul-08 at 08:25I've updated my code thanks to the great comments posted to my question.
QUESTION
I am currently using a generative RNN to classify indices in a sequence (sort of saying whether something is noise or not noise).
My input in continuous (i.e. a real value between 0 and 1) and my output is either a (0 or 1).
For example, if the model marks a 1 for numbers greater than 0.5 and 0 otherwise,
[.21, .35, .78, .56, ..., .21] => [0, 0, 1, 1, ..., 0]:
ANSWER
Answered 2017-Dec-19 at 19:21First up, it looks like you're doing seq-to-seq modelling. In this kind of problems it's usually a good idea to go with encoder-decoder architecture rather than predict the sequence from the same RNN. Tensorflow has a big tutorial about it under the name "Neural Machine Translation (seq2seq) Tutorial", which I'd recommend you to check out.
However, the architecture that you're asking about is also possible provided that n_steps
is known statically (despite using dynamic_rnn
). In this case, it's possible compute the cross-entropy of each cells' output and then sum up all the losses. It's possible if the RNN length is dynamic as well, but would be more hairy. Here's the code:
QUESTION
I am very confused by these two parameters in the conv1d layer from keras: https://keras.io/layers/convolutional/#conv1d
the documentation says:
...ANSWER
Answered 2017-Sep-30 at 17:05You're right to say that kernel_size
defines the size of the sliding window.
The filters
parameters is just how many different windows you will have. (All of them with the same length, which is kernel_size
). How many different results or channels you want to produce.
When you use filters=100
and kernel_size=4
, you are creating 100 different filters, each of them with length 4. The result will bring 100 different convolutions.
Also, each filter has enough parameters to consider all input channels.
The Conv1D layer expects these dimensions:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install sequence-classification
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page