from walnutclient import *

#objWalnutClient= walnutclient(5001,'localhost',selProject.ModelMap.RawXML)
strDataFolder = "/home/chandan/chandan/code/brainscience/"
strRootFolder = "/home/chandan/chandan/code/brainscience/"
strAppFolder = "curious/"
strModelFolder = 'curiousWorkbench/test/models/'


strModelFile = 'model1.txt'
strDataFile ='Test_003_1_WordList.csv'

inputModelFile = strRootFolder + strAppFolder + strModelFolder + strModelFile
strInputDataFile = strDataFolder + strDataFile

fo = open(inputModelFile,'r')
strRawModelXML = fo.read()

objwalnutclient = walnutclient(5001, 'localhost',strRawModelXML )
runValue = objwalnutclient.runNetworkWithFile(strInputDataFile, 'CSV',True,False,False,True)
print runValue['returnValue']
Пример #2
0
 def getWalnutResponse(self, trainValue):
     strRawModelXML = self.getModelFile()
     objWalnutClient= walnutclient(5001,'localhost',strRawModelXML)
     runValue =  objWalnutClient.runNetworkWithValue(trainValue, False,False,False,True)
     return runValue
Пример #3
0
def trainProject(request, project_id):
    dataFileList = DataFile.objects.order_by('-LastUpdated')
    strMsg = ""
    selProject=get_object_or_404(Project, pk=project_id)
    objWalnutClient= walnutclient(5001,'localhost',selProject.ModelMap.RawXML)

    if 'trainForValue' in request.POST:
        trainValue=request.POST["txtTrain"]
        if trainValue.strip() !='':
            runValueList=None
            modelMap = selProject.ModelMap

            runValue =  objWalnutClient.runNetworkWithValue(trainValue, False,False,False,True)

            predictionGraph = runValue["PredictionGraph"]
            #FormattedReturn=formatPrediction(0, returnValue)
            template = loader.get_template('curiousWorkbench/trainProject.html')
            predictionGraphImagePath = drawPredictionGraph(predictionGraph)
            context =  RequestContext(request, {
            'project' : selProject,
            'modelMap': modelMap,
            'runValue':runValue["returnValue"],
             'strMsg':runValue["strMsg"],
             'predictionGraphImagePath':predictionGraphImagePath,
             'dataFileList': dataFileList,
            })
        else:
            modelMap = selProject.ModelMap
            template = loader.get_template('curiousWorkbench/trainProject.html')
            context =  RequestContext(request, {
            'project' : selProject,
            'modelMap': modelMap,
            'runValue':'',
             'strMsg':'',
             'predictionGraphImagePath':'',
             'dataFileList': dataFileList,
            })
    elif 'trainWithFile' in request.POST:
        if request.POST["rdoDataFile"] != "0":
            trainValueFile=request.POST["rdoDataFile"]
            runValue = objWalnutClient.runNetworkWithFile(trainValueFile,'CSV',True,False,False,True)
        else:
            runValue = {"returnValue":"No File Selected","strMsg":""}
        selProject=get_object_or_404(Project, pk=project_id)
        modelMap = selProject.ModelMap


        template = loader.get_template('curiousWorkbench/trainProject.html')
        context =  RequestContext(request, {
        'project' : selProject,
         'modelMap': modelMap,
         'runValue':runValue['returnValue'],
         'strMsg':runValue['strMsg'],
         'dataFileList': dataFileList
        })
    elif 'resetProject' in request.POST:
        returnV = objWalnutClient.resetTraining()

        #objNetwork = Network()
        #objNetwork.resetTraining(project_id)
        selProject=get_object_or_404(Project, pk=project_id)
        modelMap = selProject.ModelMap


        template = loader.get_template('curiousWorkbench/trainProject.html')
        context =  RequestContext(request, {
        'project' : selProject,
         'modelMap': modelMap,
         'runValue':"--",
         'strMsg':"",
         'dataFileList': dataFileList
        })
    else:
        selProject=get_object_or_404(Project, pk=project_id)
        modelMap = selProject.ModelMap
        template = loader.get_template('curiousWorkbench/trainProject.html')
        context =  RequestContext(request, {
        'project' : selProject,
         'modelMap': modelMap,
         'runValue':"--",
         'strMsg':"",
         'dataFileList': dataFileList,
        })

    return HttpResponse(template.render(context))