Export (0) Print
Expand All

Update (clsMiningModel)

SQL Server 2000

Update (clsMiningModel)

The Update method of an object of ClassType clsMiningModel saves the mining model along with its Columns collection to the repository.




The mining model object to update.


For mining models of SubClassType sbclsOlap, the Update method checks to see whether the Columns collection is empty. If it is, the method automatically populates the Columns collection based on the structure of the source cube before saving to the repository.

By default, only the Column object that corresponds to the CaseLevel property of the mining model is enabled; the CaseLevel is the same as the level object from the SourceCube of the mining model, and it provides the cases for the model. Users can then select and enable other columns by setting the IsDisabled property of the Column objects to False.

Creating an OLAP Mining Model

The following example creates an OLAP mining model without explicitly assigning any columns to the model. The Update method then automatically builds the structure of the Columns collection based upon the source cube's architecture and sets their IsDisabled properties to True. The example then enables some of the columns and makes the UnitSales column predictable.

Public Sub CreateOlapMiningModel_2()
' Declarations - Identify all of the variables that will be needed to
' create the data mining model.
    Dim dsoSvr As New DSO.Server
    Dim dsoDmm As DSO.MiningModel
    Dim dsoColumn As DSO.Column
    Dim dsoRole As DSO.Role
    Dim dsoNestedCol As DSO.Column

' Before the model is created, check for a previous incarnation of it.
' If it exists, delete it. Then create a new one.
' Give the new model a new data source, and give it a role.
' Then describe the model for browsing of the schema, and declare the
' algorithm that will be used to predict with.
' Lastly, set up the OLAP properties that will be needed by the model.
    dsoSvr.Connect "LocalHost"
    Set dsoDb = dsoSvr.MDStores("Foodmart 2000")
    If Not dsoDb.MiningModels("CustSales_Olap2") Is Nothing Then
        dsoDb.MiningModels.Remove "CustSales_Olap2"
    End If
    Set dsoDmm = dsoDb.MiningModels.AddNew("CustSales_Olap2", sbclsOlap)

    'Create a new mining model role called All Users.
    Set dsoRole = dsoDmm.Roles.AddNew("All Users")

    dsoDmm.Description = "Analyzes the purchasing behavior of customers"
    dsoDmm.MiningAlgorithm = "Microsoft_Decision_Trees"
    dsoDmm.SourceCube = "Sales"
    dsoDmm.CaseDimension = "Customers"
    dsoDmm.CaseLevel = "Name"
    dsoDmm.TrainingQuery = "" 'Let DSO figure out the training query.
' In the next step, the Update method checks to see whether there are any
' columns in the columns collection. In this case, because there aren't
' any, the update method will automatically add columns based on the
' structure of the Sales cube.
    dsoDmm.Update 'Let DSO automatically populate the Columns collection.
    'Enable the Products dimension.
    'Set dsoColumn = dsoDmm.Columns("Products")
    'dsoColumn.IsDisabled = False

    'Make the Unit Sales measure predictable.
    Set dsoColumn = dsoDmm.Columns("Unit Sales")
    'Enable the column.
    dsoColumn.IsDisabled = False
    'Make the column predictable.
    dsoColumn.IsPredictable = True

    ' Set the last updated date to today's date.
    dsoDmm.LastUpdated = Now
    ' Save the model's meta data.
' Lock the cube, process it, and then unlock it.
' Note: During processing a number of events will be fired. These events
' are trapped by the database object's ReportAfter, Report Before,
' ReportProgress, and ReportError events.
    'Because the model is about to be processed, it must be locked.
    dsoDmm.LockObject olapLockProcess, "Processing the data mining model in sample code"
    'Process the model.
    dsoDmm.Process processFull
    'Unlock the model.
End Sub
© 2015 Microsoft