Explain how LSTM is used for Classification?
MACHINE LEARNING RECIPES DATA CLEANING PYTHON DATA MUNGING PANDAS CHEATSHEET     ALL TAGS

Explain how LSTM is used for Classification?

Explain how LSTM is used for Classification?

This recipe explains how LSTM is used for Classification

0

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

Ensemble Machine Learning Project - All State Insurance Claims Severity Prediction
In this ensemble machine learning project, we will predict what kind of claims an insurance company will get. This is implemented in python using ensemble machine learning algorithms.

Machine Learning project for Retail Price Optimization
In this machine learning pricing project, we implement a retail price optimization algorithm using regression trees. This is one of the first steps to building a dynamic pricing model.

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.

Identifying Product Bundles from Sales Data Using R Language
In this data science project in R, we are going to talk about subjective segmentation which is a clustering technique to find out product bundles in sales data.

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.

Learn to prepare data for your next machine learning project
Text data requires special preparation before you can start using it for any machine learning project.In this ML project, you will learn about applying Machine Learning models to create classifiers and learn how to make sense of textual data.

Mercari Price Suggestion Challenge Data Science Project
Data Science Project in Python- Build a machine learning algorithm that automatically suggests the right product prices.

Predict Credit Default | Give Me Some Credit Kaggle
In this data science project, you will predict borrowers chance of defaulting on credit loans by building a credit score prediction model.

Loan Eligibility Prediction using Gradient Boosting Classifier
This data science in python project predicts if a loan should be given to an applicant or not. We predict if the customer is eligible for loan based on several factors like credit score and past history.

Sequence Classification with LSTM RNN in Python with Keras
In this project, we are going to work on Sequence to Sequence Prediction using IMDB Movie Review Dataset​ using Keras in Python.