Beispiel #1
0
  def store_coeff(self,name,value,fnames=None,jsonformat=True):
    if jsonformat:
      d = {"coeffs":[round(x,3) for x in list(value)]}
      if fnames is not None: d["fnames"] = list(fnames)
      open(os.path.join(misc.coef_dir(),name+'.json'),'w').write(simplejson.dumps(d,indent=4))
    else:
      colname1 = (name,'coeffs')
      colname2 = (name,'fnames')
      if colname1 in self.coeffs: del self.coeffs[colname1]
      if colname2 in self.coeffs: del self.coeffs[colname2]

      d = {colname1:value}
      if fnames is not None: d[colname2] = fnames
      self.coeffs = pd.concat([self.coeffs,pd.DataFrame(d)],axis=1)
Beispiel #2
0
 def load_fnames(self,name,jsonformat=True):
   if jsonformat:
     d = simplejson.loads(open(os.path.join(misc.coef_dir(),name+'.json')).read())
     return d["fnames"]
   else:
     return self.coeffs[(name,'fnames')].dropna()
Beispiel #3
0
 def load_coeff(self,name,jsonformat=True):
   if jsonformat:
     d = simplejson.loads(open(os.path.join(misc.coef_dir(),name+'.json')).read())
     return np.array(d["coeffs"])
   else:
     return self.coeffs[(name,'coeffs')].dropna()