Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self, model, dataset):
self.model = model
self.dataset = dataset
self.TP, self.TN, self.FP, self.FN = 0, 0, 0, 0
self.Losses = [0.0] * self.dataset.Length()
'''
Protoclass in ['REGRESS', 'CLASSFY', 'CLUASTER']
'''
self.Protoclass = ModelBase.AllModelInfo()[self.model.prototype]['modeltype']
def __init__(self, taskid, mdinfo, ds, method, classfeatureindex = None):
'''
classfeatureindex和训练得到的模型是紧密相关的,对classfeatureindex的改动会牵涉到对模型的改动,因此classfeatureindex一定要去db_model的classfeatureindex
'''
clsname = mdinfo.modeltype
if (clsname.upper() in ModelBase.AllModelInfo().keys()):
# dataset is load from Dataset.GetDataset
ds['view'].classfeatureindex = mdinfo.classfeatureindex
md = ModelBase.AllModelInfo()[clsname.upper()]['cls'](dataset = ds['view'])
self.dataset = ds['view']
self.model = md
self.Load(mdinfo.model_path)
self.assessmodel = assessment.Assessment(self.model, self.dataset)
def __init__(self, taskid, mdinfo, ds):
'''
Instance and run Model according to given `model` and `dataset`
mdinfo is a MLModel object(Database record)
ds is {'info':dsinfo, 'view':dataset} or {'info':oldsinfo, 'view':dataset} while
dbds and oldsds is Dataset or OnlineDataset object
lcdt is datasets.localdata.LocalData object
'''
clsname = mdinfo.modeltype
# possibles = globals()
# possibles.update(locals())
if (clsname.upper() in ModelBase.AllModelInfo().keys()): # and (clsname in possibles.keys()):
# dataset.classfeatureindex is determined by mdinfo(and when training md.classfeatureindex is determined by dataset.classfeatureindex)
ds['view'].classfeatureindex = mdinfo.classfeatureindex
# need to set args to __init__
# md = possibles.get(clsname)(dataset = ds['view'])
# print ModelBase.AllModelInfo()[clsname.upper()]
md = ModelBase.AllModelInfo()[clsname.upper()]['cls'](dataset = ds['view'])
md.positive = mdinfo.positive
md.negative = mdinfo.negative
md.classfeatureindex = mdinfo.classfeatureindex
md.loss = {
'QUAD': ModelBase.QuadLoss
,'BIN': ModelBase.BinLoss
,'ABS': ModelBase.AbsLoss
,'LOG': ModelBase.LogLoss
}[mdinfo.loss]
def __init__(self, taskid, mdinfo, ds):
clsname = mdinfo.modeltype
if (clsname.upper() in ModelBase.AllModelInfo().keys()):
# dataset.classfeatureindex is determined by mdinfo(and when training md.classfeatureindex is determined by dataset.classfeatureindex)
ds['view'].classfeatureindex = mdinfo.classfeatureindex
md = ModelBase.AllModelInfo()[clsname.upper()]['cls'](dataset = ds['view'])
self.dataset = ds['view']
self.model = md
self.Load(mdinfo.model_path)