コード例 #1
0
ファイル: modelOperation.py プロジェクト: vadgama/MLW
 def nyObjOfModel(self, pmmlObj, singMod):
     import nyoka.PMML43Ext as ny
     if singMod['pmmlModelObject'].__dict__[
             'original_tagname_'] == 'MiningModel':
         nyokaObj = ny.PMML(MiningBuildTask=pmmlObj.MiningBuildTask,
                            DataDictionary=pmmlObj.DataDictionary,
                            MiningModel=[singMod['pmmlModelObject']])
     elif singMod['pmmlModelObject'].__dict__[
             'original_tagname_'] == 'DeepNetwork':
         nyokaObj = ny.PMML(DataDictionary=pmmlObj.DataDictionary,
                            DeepNetwork=[singMod['pmmlModelObject']])
     else:
         nyokaObj = None
     return nyokaObj
コード例 #2
0
ファイル: nyokaPMMLUtilities.py プロジェクト: vadgama/MLW
    def getPmml(self, architecture):

        fName = 'classification'
        lenOfArch = len(architecture)
        mName = 'Keras Model'

        netWorkInfo = []
        scriptVal = []
        extensionInfoForData = [pml.Extension(value=[], anytypeobjs_=[''])]
        dataVal = {}
        for counta, j in enumerate(architecture):
            if counta == 0:
                someConectionId = 'na'
            else:
                someConectionId = tempConId
            if j['itemType'] in ['CODE']:
                # print ('##################',j)
                scriptFile = open(j['filePath'], 'r')
                scriptCode = scriptFile.read()
                scriptCode = scriptCode.replace('<', '&lt;')
                scriptInfo = {}
                scrptVal = []
                # dataVal['scriptUrl']=j['url']
                useFor = j['useFor']
                extensionInfoForScript = [
                    pml.Extension(value=scrptVal, anytypeobjs_=[''])
                ]
                scrp = pml.script(content=scriptCode,
                                  Extension=extensionInfoForScript,
                                  for_=useFor)
                scriptVal.append(scrp)
                tempConId = None
            elif j['itemType'] in ['DATA']:
                try:
                    dataVal['dataUrl'] = j['filePath']
                    extensionInfoForData = [
                        pml.Extension(value=dataVal, anytypeobjs_=[''])
                    ]
                except:
                    pass
                tempConId = None

            elif j['itemType'] == 'FOLDING':
                #         print (j)
                for k in j['children']:
                    tempdata7 = self.convertToStandardJson(k)
                    tempdata7['connectionLayerId'] = someConectionId
                    tempConId = tempdata7['layerId']
                    pp = addLayer(tempdata7)
                    netWorkInfo.append(pp)
                    someConectionId = tempConId
            else:
                # print ('Start of tamasha$$$$$$$$$$',j)
                tempdata7 = self.convertToStandardJson(j)
                tempdata7['connectionLayerId'] = someConectionId
                tempConId = tempdata7['layerId']
                # print ('pakda', tempdata7)
                pp = self.addLayer(tempdata7)
                netWorkInfo.append(pp)

        kk = pml.DeepNetwork(modelName=mName,
                             functionName=fName,
                             NetworkLayer=netWorkInfo,
                             numberOfLayers=lenOfArch)
        tt = pml.Timestamp(datetime.now())
        hd = pml.Header(copyright="Copyright (c) 2018 Software AG",
                        Extension=extensionInfoForData,
                        description="Neural Network Model",
                        Timestamp=pml.Timestamp(datetime.now()))

        jj = pml.PMML(version="4.3Ext",
                      script=scriptVal,
                      Header=hd,
                      DeepNetwork=[kk])
        return jj