Class Reference
IRIS for UNIX 2019.3
InterSystems: The power behind what matters   
Documentation  Search
  [ENSLIB] >  [%iKnow] >  [Classification] >  [IKnowBuilder]
Private  Storage   

class %iKnow.Classification.IKnowBuilder extends Builder

Parent class for any iKnow-based %iKnow.Classification.Builder implementations, providing common infrastructure abstracting a few iKnow API calls. IKnowBuilder implementations assume category specs are %iKnow.Filters.Filter instances in their string representation.

Inventory

Parameters Properties Methods Queries Indices ForeignKeys Triggers
4 18


Summary

Properties
Categories ClassificationMethod Description DocumentVectorLocalWeights
DocumentVectorNormalization DomainId EntityRole MetadataField
MethodBuilder MinimumSpread MinimumSpreadPercent TermSelectionMetric
Terms TestSet TrainingSet

Methods
%%OIDGet %AddCRC %AddCategory %AddCooccurrence
%AddEntity %AddTerm %AddTermInternal %AddTermsFromSQL
%AddToSaveSet %BindExport %BuildObjectGraph %ClassIsLatestVersion
%ClassName %Close %ConstructClone %CreateClassifierClass
%DispatchClassMethod %DispatchGetModified %DispatchGetProperty %DispatchMethod
%DispatchSetModified %DispatchSetMultidimProperty %DispatchSetProperty %DropDictionary
%ExportDataTable %Extends %GenerateClassifier %GetCandidateTerms
%GetCategoryFilters %GetCategoryInfo %GetCategoryPosition %GetParameter
%GetRecordCount %GetTermIDs %GetTermInfo %GetTermPosition
%GetTerms %IncrementCount %IsA %IsModified
%LoadFromDefinition %LoadFromModel %LoadMetadataCategories %New
%NormalizeObject %ObjectModified %OnLoadFromDefinition %OnNew
%OriginalNamespace %PackageName %PopulateTerms %RemoveFromSaveSet
%RemoveTerm %RemoveTermAtIndex %RemoveTermEntryAtIndex %Reset
%SerializeObject %SetModified %TestClassifier %ValidateObject
ClassificationMethodSet GetColumnName GetCoocSpread TestSetSet
TrainingSetSet

Subclasses

Properties

• property DomainId as %Integer;
The iKnow domain this categorization model is built from
• property MetadataField as %String;
If set, this metadata field contains the actual category value for each source
• property TestSet as %iKnow.Filters.Filter;
• property TrainingSet as %iKnow.Filters.Filter;
The sample set of the domain to be used for training this model

Methods

• classmethod %DropDictionary(pDictId) as %Status
• method %GetCandidateTerms(pType As %String = "entity") as %Status
^||%IK.TermCandidates(id) = $lb(value, spread) ^||%IK.TermCandidates(id, j) = [spread in category j]
• method %GetCategoryFilters(Output pFilters, pIntersectWithFilter As %iKnow.Filters.Filter = "", pCheckIfEmpty As %Boolean = 0) as %Status
Builds an array of %iKnow.Filters.Filter objects for the categories registered in this Builder instance.
• method %GetCategoryInfo(Output pCategories) as %Status
Returns all categories added so far: pCategories(n) = $lb([name], [record count])
• method %GetRecordCount(Output pSC As %Status) as %Integer
• method %GetTermIDs(Output pTermInfo, Output pDictId As %Integer, Output pDictMap) as %Status
Returns an array for the current builder terms: pTermInfo(i, "id", n) = entity ID / crc ID / cooc entity IDs / dictItemId
• method %GetTermInfo(Output pTermInfo, pIncludeCategoryDetails As %String = "") as %Status
Returns an array for the current builder terms: pTermInfo(i, "spread") = [spread in training set] pTermInfo(i, "spread", j) = [spread in training set for category j] pTermInfo(i, "frequency", j) = [freq in training set for category j]
• method %LoadMetadataCategories(pFieldName As %String) as %Status

Creates (appends) categories for each of the available values of a given metadata field pFieldName in the full domain (thus ignoring TrainingSet).

Note: as category names are case sensitive, it is highly recommended to use a case-sensitive metadata field.

• private method %OnCreateExportTable(pClassDef As %Dictionary.ClassDefinition, pVerbose As %Boolean) as %Status
Callback invoked by %ExportDataTable when creating the export table definition.
• private method %OnExportTable(pClassName As %String, pVerbose As %Boolean, pTracking As %Boolean) as %Status
Callback invoked by %ExportDataTable to load the data into export table pClassName.
• private method %OnGenerateClassifier(ByRef pDefinition As %iKnow.Classification.Definition.Classifier, pVerbose As %Boolean = 1, pIncludeBuilderInfo As %Boolean = 0) as %Status
Appends the ClassificationMethod element for this type of classifier.
• method %OnNew(pDomainName As %String = "", pTrainingSet As %iKnow.Filters.Filter = "", pMethod As %String = "naiveBayes") as %Status
This callback method is invoked by the %New method to provide notification that a new instance of an object is being created.

If this method returns an error then the object will not be created.

It is passed the arguments provided in the %New call. When customizing this method, override the arguments with whatever variables and types you expect to receive from %New(). For example, if you're going to call %New, passing 2 arguments, %OnNew's signature could be:

Method %OnNew(dob as %Date = "", name as %Name = "") as %Status If instead of returning a %Status code this returns an oref and this oref is a subclass of the current class then this oref will be the one returned to the caller of %New method.

• private method %OnReset() as %Status
• method %PopulateTerms(pCount As %Integer = 100, pType As %String = "entity", pMetric As %String = "BM25", pPerCategory As %Boolean = 0) as %Status

This %PopulateTerms implementation accepts "BM25" and "TFIDF" as acceptable values for pMetric. See also the class reference for this method in %iKnow.Classification.Builder.

• method %TestClassifier(pTestSet As %RawString = "", Output pResult, Output pAccuracy As %Double, pCategorySpec As %String = "", pVerbose As %Boolean = 0) as %Status

Utility method to batch-test the classifier against a test set pTestSet, which can be supplied as an %iKnow.Filters.Filter object or its serialized form. Per-record results are returned through pResult:
pResult(n) = $lb([record ID], [actual category], [predicted category])

pAccuracy will contain the raw accuracy (# of records predicted correctly) of the current model. Use %iKnow.Classificaton.Utils for more advanced model testing.

If the current model's category options were added through %AddCategory without providing an appropriate category filter specification, rather than through a call to %LoadMetadataCategories (which sets MetadataField), supply a metadata field through pCategorySpec where the actual category values to test against can be found.

• method GetCoocSpread(pDomainId As %Integer, pIDs As %List, pTrainingFilter As %iKnow.Filters.Filter = "", pMode As %String(VALUELIST=",spread,freq")="spread", Output pSC As %Status) as %Integer
Helper method to retrieve the Cooccurrence spread for a set of sources defined by pTrainingFilter
• method TestSetSet(pFilter As %iKnow.Filters.Filter) as %Status
This is a Set accessor method for the TestSet property.
• method TrainingSetSet(pFilter As %iKnow.Filters.Filter) as %Status
This is a Set accessor method for the TrainingSet property.


Copyright (c) 2019 by InterSystems Corporation. Cambridge, Massachusetts, U.S.A. All rights reserved. Confidential property of InterSystems Corporation.