Explain how LSTM is used for Classification?

Explain how LSTM is used for Classification?

Explain how LSTM is used for Classification?

This recipe explains how LSTM is used for Classification


Recipe Objective.

Explain how LSTM is used for Classification?

LSTM is mainly used for text classification so, we will take the example of it.

We will create a LSTM model for text classification

Step 1- Loading the text.

First we will load the text from our drive. pharma_train=pd.read_csv('/content/drive/My Drive/Python/pharma/train.csv') pharma_train

Step 2- Preprocessing of text.

MAX_WORDS = 10000 MAX_LENGTH = 150 # This is fixed. EMBEDDING_DIM = 100 tokenizer = Tokenizer(num_words=MAX_NB_WORDS, filters='!"#$%&()*+,-./:;<=>?@', lower=True) tokenizer.fit_on_texts(parma_train['job_discription'].values) word_index = tokenizer.word_index print('tokens' % len(word_index)) X = tokenizer.texts_to_sequences(df['job_discription'].values) X = pad_sequences(X, maxlen=MAX_LENGTH) Y = pd.get_dummies(pharma_train['job_type']).values

Step 3- Splitting the dataset

We will split the dataset into training and testing

X_train, X_test, Y_train, Y_test = train_test_split(X,Y, test_size = 0.10, random_state = 42)

Step 4- Creating a LSTM model.

we will create a LSTM model and pass our dataset through it.

model = Sequential() model.add(Embedding(MAX_WORDS, EMBEDDING_DIM, input_length=X.shape[1])) model.add(SpatialDropout1D(0.2)) model.add(LSTM(50)) model.add(Dense(32, activation='softmax')) model.compile(loss='categorical_crossentropy', optimizer='adam', metrics=['accuracy']) history = model.fit(X_train, Y_train, epochs=10, batch_size=50,validation_split=0.1)

Relevant Projects

Data Science Project on Wine Quality Prediction in R
In this R data science project, we will explore wine dataset to assess red wine quality. The objective of this data science project is to explore which chemical properties will influence the quality of red wines.

Topic modelling using Kmeans clustering to group customer reviews
In this Kmeans clustering machine learning project, you will perform topic modelling in order to group customer reviews based on recurring patterns.

Customer Churn Prediction Analysis using Ensemble Techniques
In this machine learning churn project, we implement a churn prediction model in python using ensemble techniques.

Resume parsing with Machine learning - NLP with Python OCR and Spacy
In this machine learning resume parser example we use the popular Spacy NLP python library for OCR and text classification.

Ecommerce product reviews - Pairwise ranking and sentiment analysis
This project analyzes a dataset containing ecommerce product reviews. The goal is to use machine learning models to perform sentiment analysis on product reviews and rank them based on relevance. Reviews play a key role in product recommendation systems.

Human Activity Recognition Using Multiclass Classification in Python
In this human activity recognition project, we use multiclass classification machine learning techniques to analyse fitness dataset from a smartphone tracker.

Music Recommendation System Project using Python and R
Machine Learning Project - Work with KKBOX's Music Recommendation System dataset to build the best music recommendation engine.

Zillow’s Home Value Prediction (Zestimate)
Data Science Project in R -Build a machine learning algorithm to predict the future sale prices of homes.

Data Science Project - Instacart Market Basket Analysis
Data Science Project - Build a recommendation engine which will predict the products to be purchased by an Instacart consumer again.

Build an Image Classifier for Plant Species Identification
In this machine learning project, we will use binary leaf images and extracted features, including shape, margin, and texture to accurately identify plant species using different benchmark classification techniques.