One of the tasks that you probably find most time consuming and annoying in SEO is keyword clustering.
If you’ve ever had to do this with thousands or tens of thousands of terms, you know what we’re talking about.
It’s a nightmare.
And a drain on hours and resources.
That’s why we’ve prepared a Python script so that thanks to Google Colab you can automate keyword clustering with AI.
Finally, you will avoid having to manually check each word of your keyword research one by one to group them.
Let’s see what we are talking about:
Keyword clustering through artificial intelligence with Python
To make use of the script, you will only need:
- Your keyword list (at the end of this article you will find a template where to paste your keywords)
- and an OpenIA Api key.
As you can see, two very simple requirements.
Content script functions to categorise keywords:
Now, we are going to explain you what tasks are executed by the script programmed by our Head of SEO Alvaro Peña de Luna:
- Import the keywords from your file “Keywords.csv”.
- Generate the categories to sort the set of keywords into
- Returns the name of the categories to group the keywords into
- Assigns the keyword to the category created in the previous step
Well, as you can see, the code performs 4 tasks that otherwise can take hours.
A great idea, don’t you think?
Now let’s see the steps you need to take advantage of something so powerful.
Steps before running the script to cluster keywords:
The first thing you need to do is run the Python code in your browser using Google Colab.
We recommend you to check our article on How to get keyword search intent with AI, where we explain it step by step.
Also in the next section we explain to you how to run it step by step or if you prefer you can go directly to the video.
Anyway, leave us a comment with your doubts if you don’t manage to run it correctly.
We will use the same .csv template in a completely different scenario.
But we will still use Natural Language Processing (NLP) with artificial intelligence,
And remember…
Save a copy of .csv file as “keywords.csv”. Be careful not to include (1) if such a file already exists on your computer.
Let's go to our Colab and run script
- Create a list of keywords: to run the script, you will need a .CSV file with a header called “keywords” (at the end of this article, you will find a template to download).
- Obtain an OpenAI key (you need to have an OpenAI account and API key to be able to use the GPT-3 language model) if you don’t already have one.
- Make a copy of the file we provide, save it as a CSV and run the code in Colab: you must access Colab in tools and run each cell by clicking on “Play” in the top left corner.
- Install the dependencies: you must install all the dependencies needed to run the code. This is done by clicking on the corresponding cell and waiting for it to run without errors.
- Upload the CSV file with your keywords: the CSV file with the keywords must be uploaded by clicking on “Upload” in the corresponding cell and selecting the file.
- Set the necessary parameters for the correct functioning of the script: This includes the OpenAI secret key and the modification of the CSV file format.
- Execute the first prompt: the first prompt must be executed to create an empty list of keyword categories and batch counters.
- Run the second prompt: once you have the list of keywords, run the second prompt to categorize the keywords according to their similarity.
- Call OpenAI: OpenAI must be called to obtain the categories to which the keywords belong.
- Format the response: the response obtained from OpenAI must be formatted to display the categories in a readable format.
- Iterate until all the keywords are used: iterate until all the keywords are used and all the categories are obtained.
Written in this way, it seems very complicated, but we have prepared a short explanatory video with a demo of the process so that you can better understand the script and know how to execute it:
This content is generated from the audio voiceover so it may contain errors.
(00:00) very good welcome and welcome to a new video of iSocialWeb on artificial Intelligence applied to the cathedral I am Luis and go you to explain step by step how execute and comprise a Script generated by Álvaro Crag in Which We will be able to clisterizarlas a listing of keywords of form totally automatic and in so alone some segundillos for this go to use GPT3 and of Open AI Already would have to know it Is quite famous the model of language more used nowadays mainly by the ease to connect us to pencil
(00:30) of Open AI to follow this tutorial will need a listing of keywords I for example Here have exported a listing of keywords of Amazon directly ones of the keywords with more visits that have and simply csv with a headed called keywords and export it with the title keywords.cv besides will need a key of opening for this will have to have an account will have to probably enter a charge card and #depend if you have used already or no the account will have some free writings or
(01:03) you will have to pay once you have the requirements can execute the code in colab have the link in the description of the video and if you want to more information on artificial Intelligence and similar videos can see our canal where will have cases of similar use all they practical all they accompanied with a colab and all this explained step by step begin Then I execute all the code already not to have to expect to that they execute the things and do you lose the time while I explain, but basically all the basic code for by
(01:35) cells have to do click in the Play here in the left upper corner to execute each cell here have in green text preferred by pads all the commentaries that help you step by step and go explaining all what does the code, but already go it to explain so that you do not lose you here have the installation of the dependencies that need to use This goes to expand Python to allow us execute our code simply him dais to the click and click expect and would have to execute everything without problem to continuation have for
(02:05) go up your csv to collage simply dais click here will exit you a selection to go up archives choose your keyword csv and go up it to continuation go to do establish all the parameters and do a series of modifications to our contents to be able to use them with opening and our promes import all the dependencies go to read our csv of keywords and go to modify it deleting here below the title keywords to use it and giving him a separate format all by jumps of line
(02:39) using this character to be able to include it in our Front easily finally have to put here your secret key of Open AI the name says it secret only share this key with people that have confidence and that want that it use your account of Open AI since it is clear in which it allows to use the credits once execute this code and have all the data spend to the following cell and Here go to create an empty list of categories of keywords go to create some counters of batches for
(03:08) can command the things in loop and save in credits and go to use two prompts have #take here so that you can see them with main quality and go to use a first prompt that is for the following listing of keywords two jumps of line so that it operate and understand that there is a that these are ready separated and here would dip our batch of keyword will separate these by jump of line go to go working of 50 and 50 #give only the name of the generic categories one under another in which group all the keywords
(03:40) this would be what would execute the first time when the listing of keywords as you see was empty once the listing of keywords was not empty go to execute a second prompt and here have it is Very similar to the first for the following listing of words in our listing of words #give only the name of the generic categories one of drop of another in which group the keyword fits in any of these categories do not create A new category and here include already those that have created in scarce contrary #give the name of
(04:11) a specific category and very divided That is to say what want to is not repeating categories thus we spend him the listing of the Already created this is a very important detail and that if you program it from zero or are trying to do for us and can overlook you and to continuation do a call This is the typical call Open AI choose the model spend him our Chrome the number of tokens and the temperature with this always can play a poquillo to continuation formateamos a bit the response and follow iterating until
(04:41) use all the keywords that have that are in our listing our csv Here see that have the counter once surpass the counter of keywords to our number of keywords will stop literal here have a demo for example of some results that obtains us for example wireless headphones geles of nail etcetera To continuation go to do the important step already have our listing of generic categories what need now is to classify all our keywords in function to this by
(05:15) this go to do a very similar process believe an empty list execute a counter to save in resources look the number of squads that have not to spend us and go to execute the following Chrome for the following listing of words assign here by any of these and spend him our batch of words and our list of categories do The same call Open AI formateamos the result Here go to do a series of filters so that it do not wrap with the separations since they can include scripts
(05:50) they can include two points and go to formatear everything in a table and simply here at the end see that have a table created go to do a display and can see that have a series of categories in this case electronic beauty leisure furniture home and others the truth that nailed to what uses Amazon and here have in the distinct the distinct keywords that belong attack category for example electronic auricular wireless metronomes the Kindle etcetera as you see is brutal as it classifies yes that it can
(06:22) fail yes that a person manually would do it better, but clear can not work with thousands and thousands of keywords to this speed and always can do a second spent manual this can go down it is in format csv can follow processing using Python to make more modifications on these data But with this already have as you can see a classification very very effective Expect that it have liked you and remember have more videos in the canal will go up more videos So subscribe you And if it interests you the artificial Intelligence
(06:52) applied to the cathedral and see us in the following a greeting
Script and template for clustering with AI Download
What problems can I encounter when running content scripts?
- Google Colab does not locate .csv file: Sometimes, the generated CSV file may have a different encoding or elements that corrupt it and make it unreadable. To solve this problem, a demo file can be used to test the tool.
- OpenAI is not fully operational: sometimes it cannot cope with the multitude of requests it receives from all over the world. Be patient, it usually takes a short time to be at full capacity
What is a cluster?
Simply put, a cluster is a group of objects or data that share similar features.
In the case of keyword clustering, these groups are made up of words or terms that are highly semantically related to each other.
It is important to differentiate between classification and clustering.
- Classification refers to the assignment of an object to a predefined category.
- Clustering involves grouping objects into categories that are not previously defined.
In this manner, we avoid observer bias.
So: What is keyword clustering with AI?
Keyword clustering is the process of grouping keywords into clusters based on their semantic similarities. This helps to organize and structure keyword data for SEO and content strategy purposes.
Thanks to AI tools, as you have seen, you can analyze huge keyword lists much faster and more accurately than with your own eyes.
This allows you to complete keyword clustering tasks fast and efficiently.
How AI improves keyword clustering
AI algorithms can learn from data and improve over time, making keyword clustering more accurate and relevant.
AI can understand the meaning of keywords and cluster them based on semantic similarities, facilitating finer, more accurate and more efficient work.
Some advantages of using AI for keyword clustering can be summarized as follows:
- Better understanding of user intent
- Improved SEO performance
- Time and cost savings
In conclusion, keyword clustering with AI can greatly improve your SEO and marketing efforts by providing more accurate and relevant keyword data.
By following the implementation steps outlined above, you can start using AI to improve your keyword clustering process today.
What are some applications of clustering?
Clustering has a multitude of applications in the real world and in marketing in particular.
Here are some of the applications of clustering in marketing:
- Customer segmentation:
- Grouping of offers
- Market research
- Price optimization
- Customer retention
And of course, it is especially relevant when it comes to SEO.
Thanks to AI, these task that were so costly to perform have been simplified and in many cases made available to a wider range of professionals.
You will agree with us that this is very promising and that we can now execute sorting tasks at a fraction of the time and cost of just a few years ago.
Well, now that you know what clustering is all about, let’s have a little final test!
Do you want to take the plunge?
Can you tell us which of the following statements you think is true?
We couldn’t make it that easy, and the correct answer was to cluster keywords.
And the right answer is…, indeed, number 4! A good example is when a company wants to personalize its marketing strategy and needs to segment its customers into groups with similar characteristics and needs. Clustering is a super powerful tool.
Would you like to know more about the keyword clustering technique to identify the most relevant keywords for your business?