Text Mining Action Set
Assign Discovered Topics to New Documents Using the Analytic Store
This section contains PROC CAS code.
Note: Input data must be accessible in your CAS session, either as a CAS table or as a transient-scope table. A CAS table has a two-level name: the first level is your CAS engine libref, and the second level is the table name. You refer to this table in the CAS procedure by specifying only the second level. For more information about two-level names, see Chapter 2, Shared Concepts (SAS Viya: Machine Learning Procedures). A transient-scope table is called directly from the action and exists in memory for the duration of the action. For more information about accessing data, see SAS Viya: System Programming Guide. For more information about PROC CAS and programming in CASL, see SAS Cloud Analytic Services: CASL Programmer’s Guide and SAS Cloud Analytic Services: CASL Reference.
This example creates and uses an analytic store to score new data. It assumes that you have already run the code in Example 39.1.
The following code creates the saveState data table by using the tmMine action:
proc cas;
loadactionset "textMining";
action tmMine;
param
docId="did"
documents={ name="reviews"}
text="text"
nounGroups= False
tagging = True
stemming= True
stopList ={ name="en_stoplist"}
parseConfig={name="config", replace=TRUE}
parent ={ name="parent",replace=TRUE}
offset ={name="offset",replace=TRUE}
terms ={ name="terms", replace=TRUE}
reduce=2
k=3
docPro ={ name="docpro", replace=TRUE}
topics ={ name="topics", replace=TRUE}
u ={ name="svdu", replace=TRUE}
numLabels=3
topicDecision=True
saveState={ name="astoreTable", replace=TRUE}
;
run;
quit;
data mycas.scoreReviews;
infile datalines delimiter='|' missover;
length text $300;
input text$ did;
datalines;
Loved the movie! I watched it twice.|1
I liked the book. Great read! Good Plot!|2
;
run;
The following PROC CAS step calls the score action in the astore action set and uses the astoreTable data table that contains the input model to assign topic scores to the new documents:
proc cas;
loadactionset "astore"
action astore.score;
param
table={name="scoreReviews"}
rstore={name="astoreTable"}
out={name="docproScore", replace=TRUE}
copyVars={"did"}
;
run;
action table.fetch /table="docproScore", orderBy="did"; /*9*/
run;
quit;
Output 39.4.1 displays the contents of the mycas.docproScore table, which contains the results. Each document is assigned a score that indicates how strongly it encapsulates each of the three topics that were discovered using the initial tmMine action from this example.
Output 39.4.1: Scored Documents
| Selected Rows from Table DOCPROSCORE | |||||||
|---|---|---|---|---|---|---|---|
| _Index_ | Score for "book, plot, read" | Score for "movie, +bore, +watch" | Score for "+television, phone, resolution" | book, plot, read | movie, +bore, +watch | television, phone, resolution | did |
| 1 | 0 | 0.6815315604 | 0 | 0 | 1 | 0 | 1 |
| 2 | 0.8020158503 | 0 | 0 | 1 | 0 | 0 | 2 |
Assign Discovered Topics to New Documents Using the Analytic Store
This example is not available for the Lua programming language.
Assign Discovered Topics to New Documents Using the Analytic Store
This example is not available for the Python programming language.
Assign Discovered Topics to New Documents Using the Analytic Store
This example is not available for the R programming language.