Exemple #1
0
def tryBirthForTask(taskoutpath=None,
                    lap=None,
                    lapFrac=0,
                    targetUID=0,
                    batchID=None,
                    **kwargs):
    '''

    Post Condition
    --------------
    * Logging messages are printed.
    * HTML report is saved.
    '''
    if lap is not None:
        lapFrac = lap

    curModel, lapFrac = loadModelForLap(taskoutpath, lapFrac)
    Data = loadDataFromSavedTask(taskoutpath, batchID=batchID)

    LPkwargs = loadLPKwargsFromDisk(taskoutpath)
    SavedBirthKwargs = loadKwargsFromDisk(taskoutpath, 'args-birth.txt')

    if targetUID < 0:
        targetUID = findCompInModelWithLargestMisalignment(curModel, Data)

    BirthArgs = dict(**DefaultBirthArgs)
    BirthArgs.update(SavedBirthKwargs)
    for key, val in list(kwargs.items()):
        if val is not None:
            BirthArgs[key] = val
            print('%s: %s' % (key, str(val)))

    curLP = curModel.calc_local_params(Data, **LPkwargs)
    curSS = curModel.get_global_suff_stats(Data,
                                           curLP,
                                           trackDocUsage=1,
                                           doPrecompEntropy=1,
                                           trackTruncationGrowth=1)
    curLscore = curModel.calc_evidence(SS=curSS)

    print("Target UID: %d" % (targetUID))
    print("Current count: %.2f" % (curSS.getCountForUID(targetUID)))

    xSS = makeSummaryForBirthProposal_HTMLWrapper(
        Data,
        curModel,
        curLP,
        curSSwhole=curSS,
        targetUID=int(targetUID),
        newUIDs=list(range(curSS.K, curSS.K + int(BirthArgs['b_Kfresh']))),
        LPkwargs=LPkwargs,
        lapFrac=lapFrac,
        dataName=Data.name,
        **BirthArgs)
    '''
Exemple #2
0
def tryDeleteProposalForSavedTask(taskoutpath=None,
                                  lap=None,
                                  lapFrac=0,
                                  batchID=None,
                                  **kwargs):
    ''' Try specific delete proposal for specified taskoutpath

    Post Condition
    --------------
    * Logging messages are printed.
    '''
    if lap is not None:
        lapFrac = lap

    hmodel, lapFrac = load_model_at_lap(taskoutpath, lapFrac)
    Data = loadDataFromSavedTask(taskoutpath, batchID=batchID)
    kwargs['LPkwargs'] = loadLPKwargsFromDisk(taskoutpath)

    tryDeleteProposalForSpecificTarget_HDPTopicModel(Data, hmodel, **kwargs)
Exemple #3
0
def tryMergeProposalForSavedTask(taskoutpath=None,
                                 lap=None,
                                 lapFrac=0,
                                 batchID=None,
                                 **kwargs):
    '''

    Post Condition
    --------------
    * Logging messages are printed.
    * HTML report is saved.
    '''
    if lap is not None:
        lapFrac = lap

    hmodel, lapFrac = loadModelForLap(taskoutpath, lapFrac)
    Data = loadDataFromSavedTask(taskoutpath, batchID=batchID)
    kwargs['LPkwargs'] = loadLPKwargsFromDisk(taskoutpath)

    tryMergeProposalForSpecificTarget(Data, hmodel, **kwargs)