def predict(self,exp_uid,args_json,db,ell):

    try:
      app_id = self.app_id

      log_entry = { 'exp_uid':exp_uid,'task':'predict','json':args_json,'timestamp':utils.datetimeNow() } 
      ell.log( app_id+':APP-CALL', log_entry  )

      # convert args_json to args_dict
      try:
        args_dict = json.loads(args_json, object_pairs_hook=OrderedDict)
      except:
        error = "%s.predict failed to convert input args_json due to improper format" %(self.app_id) 
        return '{}',False,error

      # check for the fields that must be contained in args or error occurs
      necessary_fields = ['predict_id','params']
      for field in necessary_fields:
        try:
          args_dict[field]
        except KeyError:
          error = "%s.predict input arguments missing field: %s" % (self.app_id,str(field)) 
          return '{}',False,error

      predict_id = args_dict['predict_id']
      params = args_dict['params']

      if predict_id == "arm_ranking":

        alg_label = params['alg_label']

        # get list of algorithms associated with project
        alg_list,didSucceed,message = db.get(app_id+':experiments',exp_uid,'alg_list')

        # get alg_id
        for algorithm in alg_list:
          if alg_label == algorithm['alg_label']:
            alg_id = algorithm['alg_id']
            alg_uid = algorithm['alg_uid']
            num_reported_answers,didSucceed,message = db.get(app_id+':experiments',exp_uid,'num_reported_answers_for_'+alg_uid)
            if type(num_reported_answers)!=int:
              num_reported_answers=0


        # get sandboxed database for the specific app_id,alg_id,exp_uid - closing off the rest of the database to the algorithm
        rc = ResourceClient(app_id,exp_uid,alg_uid,db)

        # get specific algorithm to make calls to 
        alg = utils.get_app_alg(self.app_id,alg_id)

        # call getQuery
        scores,precisions,dt = utils.timeit(alg.predict)(resource=rc)

        log_entry_durations = { 'exp_uid':exp_uid,'alg_uid':alg_uid,'task':'predict','duration':dt } 
        log_entry_durations.update( rc.getDurations() )
        meta = {'log_entry_durations':log_entry_durations}

        import numpy
        ranks = (-numpy.array(scores)).argsort().tolist()

        n = len(scores)
        indexes = numpy.array(range(n))[ranks]
        scores = numpy.array(scores)[ranks]
        precisions = numpy.array(precisions)[ranks]
        ranks = range(n)

        targets = []
        for index in range(n):
          targets.append( {'index':indexes[index],'rank':ranks[index],'score':scores[index],'precision':precisions[index]} )

        log_entry = { 'exp_uid':exp_uid,'alg_uid':alg_uid,'timestamp':utils.datetimeNow() } 
        log_entry.update( {'targets':targets,'num_reported_answers':num_reported_answers} )

        ell.log( app_id+':ALG-EVALUATION', log_entry  )

        response_args_dict = { 'exp_uid':exp_uid,'alg_uid':alg_uid,'targets':targets,'num_reported_answers':num_reported_answers }

      args_out = {'args':response_args_dict,'meta':meta}
      predict_json = json.dumps(args_out)

      log_entry = { 'exp_uid':exp_uid,'task':'predict','json':predict_json,'timestamp':utils.datetimeNow() } 
      ell.log( app_id+':APP-RESPONSE', log_entry  )

      return predict_json,True,''
    except Exception, err:
      error = traceback.format_exc()
      log_entry = { 'exp_uid':exp_uid,'task':'predict','error':str(error),'timestamp':utils.datetimeNow(),'args_json':args_json }  
      didSucceed,message = ell.log( app_id+':APP-EXCEPTION', log_entry  )
      return '{}',False,error
Takes input from Slice expression and returns either a list,
dataset/ETHPy150Open nextml/NEXT/next/apps/CardinalBanditsPureExploration/CardinalBanditsPureExploration.py/CardinalBanditsPureExploration.predict--crossover with--dataset/ETHPy150Open blaze/blaze/blaze/expr/utils.py/replace_slices