[Music] this rapid minor tutorial will focus on text classification in rapid minor I'm going to use the real excel operator to import data from a spreadsheet which contains about 500 job postings together with the category in which they have been posted from the job postings are calculate the word frequencies and use an algorithm called K nearest neighbor to automatically categorize the documents into categories so we basically train the algorithm to categorize a document from previous examples and then it should be able to automatically categorize other ones into the correct categories later from our cross-validation we
get a nice matrix like this which shows us the performance for example here are the results for the software category it gets it right 23 times and gets it wrong a couple of times but 92% cache recall is pretty good overall is able to classify documents with 82% accuracy which isn't bad and the more documents it has the better it's going to be I'm going to step through the process I'll be using operators from the text processing and web mining extensions if you don't have these extensions installed go to the marketplace in the extensions menu
and install from there I'm using the nominal to text operator to convert the job posting information to text and applying it to a single attribute which is the job description text so job text I'm using the filter examples operator to select only job postings from certain categories I'm just selecting a few categories as you can see here the category has to be equal to food beverage hospitality or sales and so on I'm doing this as some of the categories had just too few examples to train the model on then I use the process documents from
data operator inside I begin with the extract content operator which is from the web mining extension it strips out all HTML code and tags from the text and leaves everything else transform cases converts all the text to lowercase so we can ignore capitalization I replaced a couple of tokens such as II - mail into email and I'm into I M then tokenize turns them into individual words filtered out the most common words like and and in stemmed the words which means getting rid of the pre and suffixes so experience becomes experience and experiences becomes experience
so it counts from the same filter out the single words and calculate the tf-idf score and prune out words that only appear in one document now to get the category from the reed excel operator through the process documents from data operator you have to select add meta information that'll let the category column pass through then I use the Select attributes operator to filter out some of that unnecessary amount of data tags that this parameter adds like the language or document title they are all just blank in my case so I can get rid of them
by selecting only columns with no missing values then I set the role the role that you want for the category is going to be the label which is equivalent to your Y variable in a regression so the dependent variable then the name of the label is the category column so I'm going to learn which category car is where and then try to predict the category later just pretend that your Y variable in here in terms of regression then in the cross-validation it basically takes the whole dataset grabs a random portion of it I'm using five
cross validations here so it'll do five iterations in each 80% of the day to reduce for training and the remaining 20% for testing in that way it can get a better understanding of his actual error rate and all examples can be used for training and testing cross-validation is a subprocess operator and it has two parts in the training section you add your learning algorithm here and then on the testing side you apply a model calculate the performance you can just leave those defaults there here I'm using the nearest neighbor algorithm which is the KNN operator
and you have to pick your number of neighbors I pick 3 here and then I use the cosine similarity to find the nearest neighbors which are generally appropriate for text documents or is going to run that that was actually pretty quick only five seconds from the cross-validation operator you get back your example set in its regular form also you can find some details about the model that was created so I use these five categories here then it gives you the performance accuracy of the model and the uncertainty in terms of classifying documents when it predicts
food or beverage category it gets it right more than 50 times but it gets it wrong a few times when it predicts healthcare it gets it right about 20 times and then gets it wrong a few other times it performed worse on the skilled trades one and performed the best on the software probably because there's more software words that are easier to discriminate on than compared to skilled trades and that's basically how word categorization works the reason I pick three nearest words is because I did it a few times and found that three provided the
highest accuracy you can also use the optimized parameters operator which I have pre-configured here that'll put an outer loop outside of cross-validation and it will pick the right number of nearest neighbors for you it'll run it several times and whichever number of nearest neighbors has the highest accuracy it'll pick that one as you can see here for a K of three the accuracy is highest I'm also going to look at using naive Bayes which is another popular word classification algorithm a lot of spam filters use it this one didn't get as good accuracy as KNN
but it's useful to show how important certain words are to a particular class that was pretty fast - only five seconds performance wise that 74% isn't too bad but KNN is better if you look at the district on table you can see for example the food beverage category that these were the most important words so Indian cook Korean breakfast chef HR is probably ours dollar per hour or working hours server kitchen shift so it kind of makes sense these are weightings of each word for the model for healthcare so CDA a certified dental assistant receptionist
care patient all sorts of things deal is probably doctor sales we've got telemarketing market promotion these are the stemmed words so naivebayes can be a good way to look at which words are important to classifying a document KNN won't tell you that but it can be a bit more accurate on the other hand so it's good to play with a few different types of learners you can also use support vector machines those can generally only be two classes at a time other ones can do multiple ones so that's document categorization I talked about passing a
category through the process documents up word setting the right role to the right column cross-validation and how it's good for finding proper error rate and then picking different training algorithms between KNN and naive Bayes and then looking at the accuracy of a learner as well as figuring out which words are important in terms of classifying this concludes this tutorial on text classification in rapid miner [Music] you [Music] [Music] this rapid minor tutorial will focus on text classification in rapid minor I'm going to use the real excel operator to import data from a spreadsheet which contains
about 500 job postings together with the category in which they have been posted from the job postings are calculate the word frequencies and use an algorithm called K nearest neighbor to automatically categorize the documents into categories so we basically train the algorithm to categorize a document from previous examples and then it should be able to automatically categorize other ones into the correct categories later from our cross-validation we get a nice matrix like this which shows us the performance for example here are the results for the software category it gets it right 23 times and gets
it wrong a couple of times but 92% cache recall is pretty good overall is able to classify documents with 82% accuracy which isn't bad and the more documents it has the better it's going to be I'm going to step through the process I'll be using operators from the text processing and web mining extensions if you don't have these extensions installed go to the marketplace in the extensions menu and install from there I'm using the nominal to text operator to convert the job posting information to text and applying it to a single attribute which is the
job description text so job text I'm using the filter examples operator to select only job postings from certain categories I'm just selecting a few categories as you can see here the category has to be equal to food beverage hospitality or sales and so on I'm doing this as some of the categories had just too few examples to train the model on then I use the process documents from data operator inside I begin with the extract content operator which is from the web mining extension it strips out all HTML code and tags from the text and
leaves everything else transform cases converts all the text to lowercase so we can ignore capitalization I replaced a couple of tokens such as II - mail into email and I'm into I M then tokenize turns them into individual words filtered out the most common words like and and in stemmed the words which means getting rid of the pre and suffixes so experience becomes experience and experiences becomes experience so it counts from the same filter out the single words and calculate the tf-idf score and prune out words that only appear in one document now to get
the category from the reed excel operator through the process documents from data operator you have to select add meta information that'll let the category column pass through then I use the Select attributes operator to filter out some of that unnecessary amount of data tags that this parameter adds like the language or document title they are all just blank in my case so I can get rid of them by selecting only columns with no missing values then I set the role the role that you want for the category is going to be the label which is
equivalent to your Y variable in a regression so the dependent variable then the name of the label is the category column so I'm going to learn which category car is where and then try to predict the category later just pretend that your Y variable in here in terms of regression then in the cross-validation it basically takes the whole dataset grabs a random portion of it I'm using five cross validations here so it'll do five iterations in each 80% of the day to reduce for training and the remaining 20% for testing in that way it can
get a better understanding of his actual error rate and all examples can be used for training and testing cross-validation is a subprocess operator and it has two parts in the training section you add your learning algorithm here and then on the testing side you apply a model calculate the performance you can just leave those defaults there here I'm using the nearest neighbor algorithm which is the KNN operator and you have to pick your number of neighbors I pick 3 here and then I use the cosine similarity to find the nearest neighbors which are generally appropriate
for text documents or is going to run that that was actually pretty quick only five seconds from the cross-validation operator you get back your example set in its regular form also you can find some details about the model that was created so I use these five categories here then it gives you the performance accuracy of the model and the uncertainty in terms of classifying documents when it predicts food or beverage category it gets it right more than 50 times but it gets it wrong a few times when it predicts healthcare it gets it right about
20 times and then gets it wrong a few other times it performed worse on the skilled trades one and performed the best on the software probably because there's more software words that are easier to discriminate on than compared to skilled trades and that's basically how word categorization works the reason I pick three nearest words is because I did it a few times and found that three provided the highest accuracy you can also use the optimized parameters operator which I have pre-configured here that'll put an outer loop outside of cross-validation and it will pick the right
number of nearest neighbors for you it'll run it several times and whichever number of nearest neighbors has the highest accuracy it'll pick that one as you can see here for a K of three the accuracy is highest I'm also going to look at using naive Bayes which is another popular word classification algorithm a lot of spam filters use it this one didn't get as good accuracy as KNN but it's useful to show how important certain words are to a particular class that was pretty fast - only five seconds performance wise that 74% isn't too bad
but KNN is better if you look at the district on table you can see for example the food beverage category that these were the most important words so Indian cook Korean breakfast chef HR is probably ours dollar per hour or working hours server kitchen shift so it kind of makes sense these are weightings of each word for the model for healthcare so CDA a certified dental assistant receptionist care patient all sorts of things deal is probably doctor sales we've got telemarketing market promotion these are the stemmed words so naivebayes can be a good way to
look at which words are important to classifying a document KNN won't tell you that but it can be a bit more accurate on the other hand so it's good to play with a few different types of learners you can also use support vector machines those can generally only be two classes at a time other ones can do multiple ones so that's document categorization I talked about passing a category through the process documents up word setting the right role to the right column cross-validation and how it's good for finding proper error rate and then picking different
training algorithms between KNN and naive Bayes and then looking at the accuracy of a learner as well as figuring out which words are important in terms of classifying this concludes this tutorial on text classification in rapid miner [Music] you [Music]