Explain Skip gram with subwords models from word2vec?
MACHINE LEARNING RECIPES DATA CLEANING PYTHON DATA MUNGING PANDAS CHEATSHEET     ALL TAGS

Explain Skip gram with subwords models from word2vec?

Explain Skip gram with subwords models from word2vec?

This recipe explains Skip gram with subwords models from word2vec

0

Recipe Objective

Explain Skip gram with subwords models from word2vec.

As we have discussed earlier about skip gram, which predicts the the surrounding context words within specific window given current word. The input layer contains the current word and the output layer contains the context words. The hidden layer contains the number of dimensions in which we want to represent current word present at the input layer. Subwords these are the woords which uses some letters of a subject. for e.g "gi","rl" are the subwords of "girl". Lets understand the skip gram with subword practically.

Step 1 - Install the required libraries

!pip install cython !pip install pyfasttext

Step 2 - Import the necessary libraries

from pyfasttext import FastText

Step 3 - load the sample dataset

sample = open("/content/alice_in_wonderland.txt", 'r') alice_data = sample.read()

Step 4 - load the model

model = FastText()

Step 5 - Train the model using skip gram

model.skipgram(input='alice_in_wonderland.txt', output='model', epoch=2, lr=0.7)

Step 6 - Get the subwords for some sample words

print("The subword for boy are:",model.get_all_subwords('boy'),'\n') print("The subword for girl are:",model.get_all_subwords('girl'),'\n')
The subword for boy are: ['boy', '', 'boy', 'boy>', 'oy>'] 
The subword for girl are: ['girl', '', 'gir', 'girl', 'girl>', 'irl', 'irl>', 'rl>']

Relevant Projects

Data Science Project in Python on BigMart Sales Prediction
The goal of this data science project is to build a predictive model and find out the sales of each product at a given Big Mart store.

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.

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

Choosing the right Time Series Forecasting Methods
There are different time series forecasting methods to forecast stock price, demand etc. In this machine learning project, you will learn to determine which forecasting method to be used when and how to apply with time series forecasting example.

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.

Forecast Inventory demand using historical sales data in R
In this machine learning project, you will develop a machine learning model to accurately forecast inventory demand based on historical sales data.

Human Activity Recognition Using Smartphones Data Set
In this deep learning project, you will build a classification system where to precisely identify human fitness activities.

Predict Census Income using Deep Learning Models
In this project, we are going to work on Deep Learning using H2O to predict Census income.

Predict Churn for a Telecom company using Logistic Regression
Machine Learning Project in R- Predict the customer churn of telecom sector and find out the key drivers that lead to churn. Learn how the logistic regression model using R can be used to identify the customer churn in telecom dataset.

Natural language processing Chatbot application using NLTK for text classification
In this NLP AI application, we build the core conversational engine for a chatbot. We use the popular NLTK text classification library to achieve this.