This topic describes how to prepare the data to use for topic modeling. The model uses a data sample generated by OCI GenAI. To prepare the data for this use case, you set up a dataset to use for both training and testing.
You have the option to automatically
Prepare Training
and Testing Datasets with your own data by using the
TRAIN_TEST_SPLIT
routine.
Learn how to Prepare Data.
To prepare the data for topic modeling:
-
Create and use the database to store the data.
mysql> CREATE DATABASE topic_modeling_data; mysql> USE topic_modeling_data;
-
Create the table to use for both training and testing.
mysql> CREATE TABLE movies ( description TEXT );
-
Insert the sample data into the table. Copy and paste the following commands.
INSERT INTO movies (description) VALUES ('In a post-apocalyptic wasteland, a lone survivor named Max seeks vengeance against a ruthless warlord named Immortan Joe. He joins forces with a rebel warrior named Furiosa and a small group of escapees from Joe''s citadel. Together, they embark on a dangerous journey across the desert in a battle-ready vehicle, hoping to find a better future.'); INSERT INTO movies (description) VALUES('A young man named Neo discovers that the world as he knows it is a sophisticated illusion called "the Matrix," created by sentient machines to subdue the human population. He is targeted by the machines and their agents, but is rescued by a group of rebels who introduce him to the real world. With their guidance, Neo develops his powers and fights back against the machine overlords.'); INSERT INTO movies (description) VALUES('A wealthy family, the Corleones, is drawn into the underworld of New York City as their powerful leader, Vito Corleone, tries to balance his legitimate business and criminal empire. When Vito refuses to get involved in the drug trade, he is critically wounded by a rival mobster. His son, Michael, reluctantly steps in to take revenge and protect the family business.'); INSERT INTO movies (description) VALUES('A group of scientists attempt to harness the power of a black hole, but the experiment goes awry, causing a massive explosion that threatens to destroy the Earth. A team of astronauts and scientists must work together to prevent the impending disaster and ensure the survival of humanity.'); INSERT INTO movies (description) VALUES('A young woman, Alice, finds herself in a mysterious and fantastical world called Wonderland, where she encounters a host of bizarre characters, including the Mad Hatter, the Cheshire Cat, and the Queen of Hearts. She must navigate this strange land and uncover the truth about her own identity.'); INSERT INTO movies (description) VALUES('A young man named Luke Skywalker joins forces with a group of rebels to battle the evil Galactic Empire. With the help of a wise old Jedi Master, Obi-Wan Kenobi, and a pair of droids, R2-D2 and C-3PO, Luke becomes a hero in the fight against the dark forces of the Empire, led by the sinister Darth Vader.'); INSERT INTO movies (description) VALUES('A team of scientists and explorers travel through a wormhole in space in an attempt to ensure humanity''s survival. They find themselves on an unknown planet in a distant galaxy, where they must battle a vicious alien creature and unravel the mysteries of the universe.'); INSERT INTO movies (description) VALUES('A young Viking named Hiccup aspires to hunt dragons like his tribe''s tradition. When he finally captures a rare Night Fury dragon, he forms an unlikely friendship with the creature. As he learns more about dragons, he discovers a secret that could change the course of the future for both humans and dragons.'); INSERT INTO movies (description) VALUES('A young FBI agent, Clarice Starling, is assigned to help find a serial killer who skins his victims. She interviews a brilliant but psychotic cannibal, Dr. Hannibal Lecter, who is imprisoned for murder. As they form a strange connection, Clarice uses his insights to track down the killer, while also dealing with her own personal demons.'); INSERT INTO movies (description) VALUES('A young man named Harry Potter discovers that he is a wizard and is invited to attend Hogwarts School of Witchcraft and Wizardry. There, he learns the secrets of magic and befriends other young wizards, while a dark power threatens to return to power and destroy everything he holds dear.'); INSERT INTO movies (description) VALUES('A group of criminals are given a second chance at redemption by performing a dangerous mission to enter a planet''s toxic atmosphere and destroy a massive alien threat. Led by the convicted murderer, Bishop, the team must overcome their differences and work together to save the Earth.'); INSERT INTO movies (description) VALUES('A young woman, Elle Woods, is determined to win back her ex-boyfriend by getting into Harvard Law School. Despite facing challenges and stereotypes, she proves herself to be a capable and resourceful law student, while also helping to solve a murder case.'); INSERT INTO movies (description) VALUES('A group of friends travel to a remote cabin in the woods for a vacation, but they soon discover that the place is not as peaceful as it seems. One by one, they fall victim to a group of terrifying creatures, and they must fight for their survival.'); INSERT INTO movies (description) VALUES('A young man named Marty McFly accidentally travels back in time in a time machine built by his eccentric scientist friend, Doc Brown. He must ensure his parents fall in love in the past to secure his own existence, while also dealing with the consequences of altering the past.'); INSERT INTO movies (description) VALUES('A young woman, Katniss Everdeen, volunteers to take her younger sister''s place in a brutal televised competition called the Hunger Games. She must fight for her life against other tributes while also becoming a symbol of hope and rebellion for the oppressed districts of Panem.'), ('A group of misfit criminals are assembled for a seemingly impossible heist by a mysterious mastermind, who plans to rob a secure casino. As they execute the intricate plan, they must deal with their personal conflicts and the interference of a powerful casino owner.'); INSERT INTO movies (description) VALUES('A young man named Frodo Baggins inherits a powerful ring, which he must destroy by journeying to the fires of Mount Doom. He is joined by a fellowship of companions, including a wise wizard, a noble warrior, and a loyal hobbit, as they face the dark forces of the evil wizard Sauron.'); INSERT INTO movies (description) VALUES('A young woman, Jo March, and her sisters come of age in America during the Civil War. She struggles with her aspirations as a writer, her unconventional personality, and her romantic feelings, while also dealing with the challenges of her family and society''s expectations.'); INSERT INTO movies (description) VALUES('A group of astronauts on a mission to Mars face a critical emergency when their spacecraft is severely damaged by a storm of debris. Stranded millions of miles from home, they must find a way to survive and find a way back to Earth.'); INSERT INTO movies (description) VALUES('A young man, Scott, discovers a hidden virtual world called the OASIS, where people can live out their wildest dreams. When the creator of the OASIS dies, he offers his vast fortune as the prize in a contest designed to find a worthy heir. Scott joins the contest and becomes a top contender, but he must also face real-world challenges and a corporate rival.'); INSERT INTO movies (description) VALUES('A group of high school students from different social cliques are forced to spend a Saturday together in detention. As they share their stories and secrets, they form unexpected bonds and learn that they are not so different after all.');
Learn how to Train a Model with Topic Modeling.