Quantcast
Channel: Oracle
Viewing all articles
Browse latest Browse all 1814

Blog Post: Oracle Text, Oracle R Enterprise and Oracle Data Mining - Part 2

$
0
0
This is the second blog post of a series on using Oracle Text, Oracle R Enterprise and Oracle Data Mining. Check out the first blog post of the series , as the data used in this blog post was extracted, processed and stored in a databases table. In this blog post I will show you how you use Oracle R Enterprise and the embedded R execution features of ORE to use the text from the webpages and to create a word cloud. This is a useful tool to be able to see visually what words can stand out most on your webpage and if the correct message is being put across to your customers. Prerequisites: You will need to load the following R packages into your R environment 'tm', 'word cloud' 'SnowballC'. These are required to process the following R code segments. install.packages (c( "tm", "wordcloud", "SnowballC")) library (tm) library (wordcloud) library (SnowballC) Select data from table and prepare: We need to select the data from the table in our schema and to merge it into one variable. local_data tm_data for(i in 1:nrow(local_data)) { tm_data } tm_data Create function to perform Text Mining: In my previous blog post on creating a word cloud I gave the R code. In order to allow for this R code to be run on the database server (using the embedded R execution of ORE) we need to package this text mining R code up into a ORE user defined R script. This is stored in the database. ore.scriptDrop("prepare_tm_data") ore.scriptCreate("prepare_tm_data", function (tm_data) { library(tm) library(SnowballC) library(wordcloud) txt_corpus Before we can run this user define R script, we need to ensure that we have the 'tm', 'SnowballC' and 'wordcloud' R packages installed on the Oracle Database server. On the Oracle Database server you need to rune ORE. ORE Then run the following command to install these R packages > install_packages(c('tm','wordcloud', 'SnowballC')) Run the function on the DB Server: You are now ready to run the function. In an earlier step we had gathered the data. Now we can pass this data to the in-database R script. > res The ore.doEval function is a general purpose ORE function. In this case we pass it two parameters. The first parameter is the neame of the user defined R script stored in the database, and the second parameter is the data. The function returns and ORE object that contains the word cloud graphic. Display the results: You can very easily display the results. > res This gives us the following graphic. In my next blog post, of this series, I will show you how you can use the function created above and some other bits and pieces, using some other features of ORE and also in SQL.

Viewing all articles
Browse latest Browse all 1814

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>