analytics.py 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564
  1. import pandas as pd
  2. import numpy as np
  3. import os
  4. import io
  5. import json
  6. from multiprocessing import Process
  7. import transport
  8. import sqlite3 as lite
  9. import numpy as np
  10. import transport
  11. import matplotlib.pyplot as plt
  12. import re, base64
  13. from weasyprint import HTML, CSS
  14. COLORS = ["#f79256","#7dcfb6","#fbd1a2","#00b2ca","#1d4e89","#4682B4","#c5c3c6","#4c5c68","#1985a1","#f72585","#7209b7","#3a0ca3","#4361ee","#4cc9f0","#ff595e","#ffca3a","#8ac926","#1982c4","#6a4c93"]
  15. class stdev :
  16. def __init__(self) :
  17. self.values = []
  18. def step(self,value):
  19. if value : #and type in [np.int64, np.int32,np.float64,np.float32, int]:
  20. self.values.append(value)
  21. def finalize(self):
  22. return np.std(self.values) if self.values else None
  23. # conn = lite.connect("/home/steve/healthcare-io/healthcare-io.db3")
  24. # conn.create_aggregate("stdev",1,stdev)
  25. # df = pd.read_sql("select count(distinct (json_extract(data,'$.patient_id'))) as patient_count, avg(json_array_length(data,'$.procedures')) mean, stdev(json_array_length(data,'$.procedures')) stdev from claims",conn)
  26. ROOT_FOLDER = 'stats'
  27. # plt.gcf().subplots_adjust(bottom=0.15)
  28. # from matplotlib import rcParams
  29. # rcParams.update({'figure.autolayout': True})
  30. class Chart :
  31. @staticmethod
  32. def remove_borders(axes,wedges,labels,item) :
  33. # plt.axes()
  34. axes.spines["top"].set_visible(False)
  35. # plt.axes().
  36. axes.spines["right"].set_visible(False)
  37. axes.legend(wedges, labels #,title=item['label']
  38. ,loc="upper right",fontsize=12,bbox_to_anchor=(1, 0, 0.5, 1),fancybox=True,framealpha=0.2)
  39. # plt.axes().
  40. # axes.spines["left"].set_visible(False)
  41. if 'axis' in item['chart'] :
  42. axes.set_ylabel(item['chart']['axis']['y'])
  43. axes.set_xlabel(item['chart']['axis']['x'])
  44. @staticmethod
  45. def donut(item,**args) :
  46. df = item['data']
  47. x = item['chart']['x'] #args['x']
  48. labels = item['chart']['y']
  49. labels = df[labels]
  50. # figure = plt.figure()
  51. figure, axes = plt. subplots()
  52. # wedges, texts = plt.pie(df[x],labels=labels)
  53. colors = COLORS[:len(labels)] #np.random.choice(COLORS,len(labels),replace=False)
  54. wedges = axes.pie(df[x],labels=labels,wedgeprops=dict(width=0.3),colors=colors,autopct=lambda pct: "{:.2f}%\n({:.0f})".format(pct,int((pct/100)*df[x].sum() ))) #,autopct=lambda pct: func(pct, df[x].values))
  55. # my_circle=plt.Circle( (0,0), 0.7, color='#ffffff',fill=True)
  56. # p=plt.gcf()
  57. # p.gca().add_artist(my_circle)
  58. # plt.legend(wedges, labels,title=item['label'],loc="upper right",bbox_to_anchor=(1, 0, 0.5, 1))
  59. # axes.legend(wedges[0], labels,title=item['label'],loc="upper right",bbox_to_anchor=(1, 0, 0.5, 1),framealpha=0,edgecolor='#CAD5E0',
  60. # )
  61. # x = plt.show()
  62. Chart.remove_borders(axes,wedges[0],labels,item)
  63. plt.close()
  64. return figure
  65. @staticmethod
  66. def barh(item,**args):
  67. """
  68. This function will return/render a bar chart (horizontal) which is conducive to showing distributions of things like diagnosis codes
  69. """
  70. # figure = plt.figure()
  71. figure, axes = plt. subplots()
  72. y_labels = item['chart']['y'][0]
  73. x_labels = item['chart']['x'] #[args['x']] if type(args['x']) == str else args['x']
  74. df = item['data'].iloc[:9].copy()
  75. # odf = item['data'].iloc[9:].copy().mean().to_frame().T
  76. # odf[y_labels] = 'Other'
  77. # df = df.append(odf)
  78. wedges = []
  79. # COLORS = ['#003f5c','#7a5195','#374c80','#bc5090','#ef5675','#ff764a','#ffa600']
  80. for x_ in x_labels:
  81. index = x_labels.index(x_)
  82. color = COLORS[index]
  83. w = axes.barh(df[y_labels],df[x_],align='edge',label='counts' ,color=color)
  84. wedges += [w]
  85. # labels = [name.replace('_',' ') for name in x_labels]
  86. # axes.legend(wedges,[name.replace('_',' ') for name in x_labels],
  87. # title=item['label'],
  88. # framealpha=0,
  89. # edgecolor='#CAD5E0',
  90. # loc="upper right",bbox_to_anchor=(1, 0, 0.5, 1)
  91. # )
  92. Chart.remove_borders(axes,wedges,[name.replace('_',' ') for name in x_labels],item)
  93. plt.close()
  94. return figure
  95. @staticmethod
  96. def spline(item,**args):
  97. """
  98. """
  99. df = item['data']
  100. # figure = plt.figure()
  101. figure, axes = plt. subplots()
  102. wedges = []
  103. item['chart']['x'] = [item['chart']['x']]if type(item['chart']['x']) == str else item['chart']['x']
  104. # COLORS = ['#003f5c','#7a5195','#374c80','#bc5090','#ef5675','#ff764a','#ffa600']
  105. for xl in item['chart']['x'] :
  106. x = df[xl]
  107. index = 0
  108. for yl in item['chart']['y'] :
  109. y = df[yl]
  110. color = COLORS[index]
  111. if 'scatter' in args :
  112. w = plt.plot(x,y,'o',color=color)
  113. else:
  114. w = plt.plot(x,y,color=color,marker='o')
  115. wedges += w
  116. index += 1
  117. # print (item['chart']['x'])
  118. # if 'axis' in item :
  119. # axes.set_ylabel(item['axis']['y'])
  120. # axes.set_xlabel(item['axis']['x'])
  121. # plt.title(item['label'])
  122. # axes.legend(wedges,[name.replace('_',' ') for name in item['chart']['y']],
  123. # title=item['label'],
  124. # framealpha=0,
  125. # edgecolor='#CAD5E0',
  126. # loc="upper right",bbox_to_anchor=(1, 0, 0.5, 1)
  127. # )
  128. axes.grid(b=False,which='major',axis='x')
  129. Chart.remove_borders(axes,wedges,[name.replace('_',' ') for name in item['chart']['y']],item)
  130. plt.close()
  131. return figure
  132. @staticmethod
  133. def scatter(item,**args):
  134. return Chart.spline(item,scatter=True)
  135. class Apex :
  136. """
  137. This class will format a data-frame to work with Apex charting engine
  138. """
  139. @staticmethod
  140. def apply(item):
  141. pointer = item['chart']['type']
  142. if hasattr(Apex,pointer) :
  143. pointer = getattr(Apex,pointer)
  144. options = pointer(item)
  145. options['responsive']= [
  146. {
  147. 'breakpoint': 1,
  148. 'options': {
  149. 'plotOptions':item['plotOptions'] if 'plotOptions' in item else None,
  150. }
  151. }
  152. ]
  153. return options
  154. else:
  155. print ("Oops")
  156. pass
  157. @staticmethod
  158. def scatter(item):
  159. options = Apex.spline(item)
  160. options['apex']['chart']['type'] = 'scatter'
  161. return options
  162. @staticmethod
  163. def scalar(item):
  164. _df = item['data']
  165. print (_df)
  166. name = _df.columns.tolist()[0]
  167. value = _df[name].values.round(2)[0]
  168. html = '<div class="scalar"><div class="value">:value</div><div class="label">:label</div></div>'
  169. if value > 999 and value < 1000000 :
  170. value = " ".join([str(np.divide(value,1000).round(2)),"K"])
  171. elif value > 999999 :
  172. #@ Think of considering the case of a billion ...
  173. value = " ".join([str(np.divide(value,1000000).round(2)),"M"])
  174. else:
  175. value = str(value)
  176. unit = name.replace('_',' ') if 'unit' not in item else item['unit']
  177. return {'html':html.replace(':value',value).replace(":label",unit)}
  178. @staticmethod
  179. def column(item):
  180. df = item['data']
  181. N = df.shape[0] if df.shape[0] < 10 else 10
  182. axis = item['chart']['axis']
  183. x = axis['x']
  184. if type(x) == list :
  185. x = x[0]
  186. axis['y'] = [axis['y']] if type(axis['y']) != list else axis['y']
  187. series = []
  188. for y in axis['y'] :
  189. series += [{"data": df[y].values.tolist()[:N],"name":y.upper().replace('_',' ')}]
  190. xtitle,ytitle = Apex.get_labels(item)
  191. options = {"chart":{"type":"bar"},"plotOptions":{"bar":{"horizontal":False,"width:":2,"color":["transparent"]}},"dataLabels":{"enabled":False},"legend":{"position":"right"}}
  192. options['xaxis'] = {"categories":df[x].values.tolist()[:N],"title":xtitle['title']}
  193. options['yaxis'] = ytitle
  194. options['series'] = series
  195. options['colors'] = COLORS[:df[x].size]
  196. return {"apex":options}
  197. # options = Apex.barh(item)
  198. # options['chart']['type'] = 'column'
  199. # options['plotOptions']['bar'] = {'horizontal':False,'columnWidth':'55%'}
  200. # options['stroke']={'show':True,'width':2,'colors':['transparent']}
  201. # return {"apex":options}
  202. @staticmethod
  203. def get_labels(item):
  204. xtitle = ytitle = ""
  205. if "labels" not in item['chart'] :
  206. xtitle = item['chart']['axis']['x']
  207. ytitle = item['chart']['axis']['y']
  208. else:
  209. xtitle = item['chart']['labels']['x']
  210. ytitle = item['chart']['labels']['y']
  211. xtitle = xtitle if type(xtitle) != list else xtitle[0]
  212. ytitle = ytitle if type(ytitle) != list else ytitle[0]
  213. return {"title":{"text":xtitle.lower().replace('_',' '),"style":{"fontWeight":"lighter"}}},{"title":{"text":ytitle.lower().replace('_',' '),"style":{"fontWeight":"lighter"}}}
  214. @staticmethod
  215. def bar(item):
  216. return Apex.barh(item)
  217. @staticmethod
  218. def barh(item):
  219. """
  220. rendering a horizontal bar chart assuming for now that only one series is involved
  221. @TODO: alias this with bar (!= column)
  222. """
  223. df = item['data']
  224. N = df.shape[0] if df.shape[0] < 10 else 10
  225. axis = item['chart']['axis']
  226. y = axis['y']
  227. if type(y) == list :
  228. y = y[0]
  229. axis['x'] = [axis['x']] if type(axis['x']) != list else axis['x']
  230. if not set(axis['x']) & set(df.columns.tolist()) :
  231. print (set(axis['x']) & set(df.columns.tolist()))
  232. print (axis['x'])
  233. print (df.columns)
  234. # df.columns = axis['x']
  235. series = []
  236. _min=_max = 0
  237. for x in axis['x'] :
  238. series += [{"data": df[x].values.tolist()[:N],"name":x.upper().replace('_',' ')}]
  239. _min = df[x].min() if df[x].min() < _min else _min
  240. _max = df[x].max() if df[x].max() > _max else _max
  241. xtitle , ytitle = Apex.get_labels(item)
  242. options = {"chart":{"type":"bar"},"plotOptions":{"bar":{"horizontal":True}},"dataLabels":{"enabled":False},"legend":{"position":"right"}}
  243. options['xaxis'] = {"categories":df[y].values.tolist()[:N],"title":xtitle['title']}
  244. options['yaxis'] = ytitle
  245. options['series'] = series
  246. options['colors'] = COLORS[:df[x].size]
  247. return {"apex":options}
  248. @staticmethod
  249. def spline(item):
  250. series = []
  251. df = item['data']
  252. N = df.shape[0] if df.shape[0] < 10 else 10
  253. axis = item['chart']['axis']
  254. x = axis['x']
  255. _min=_max = 0
  256. for y in axis['y'] :
  257. series += [{"data":df[y].values[:N].tolist(),"name":y.upper().replace('_',' ')}]
  258. _min = df[y].min() if df[y].min() < _min else _min
  259. _max = df[y].max() if df[y].max() > _max else _max
  260. colors = COLORS[:len(axis['y'])]
  261. options = {"chart":{"type":"line"},"series":series,"stroke":{"curve":"smooth"},"colors":colors,"legend":{"position":"right"}}
  262. xtitle , ytitle = Apex.get_labels(item)
  263. options['xaxis'] = {"categories":df[x].values[:N].tolist(),"title":xtitle['title']}
  264. options['yaxis'] = ytitle
  265. return {"apex":options}
  266. @staticmethod
  267. def donut(item):
  268. """
  269. :pre data must have more than one item otherwise just make it a scalar
  270. here we will use the key as labels and the values as the values (obviously)
  271. labels are y-axis
  272. values are x-axis
  273. """
  274. df = item['data']
  275. if df.shape [0]> 1 :
  276. y_cols,x_cols = item['chart']['axis']['y'],item['chart']['axis']['x']
  277. labels = df[y_cols].values.tolist()
  278. values = df[x_cols].values.round(2).tolist()
  279. else:
  280. labels = [name.upper().replace('_',' ') for name in df.columns.tolist()]
  281. values = df.values.round(2).tolist()[0] if df.shape[1] > 1 else df.values.round(2).tolist()
  282. colors = COLORS[:len(values)]
  283. options = {"series":values,"colors":colors,"labels":labels,"chart":{"type":"donut"},"plotOptions":{"pie":{"customScale":.8}},"legend":{"position":"right"}}
  284. return {"apex":options}
  285. pass
  286. class engine :
  287. """
  288. This engine is designed to load the configuration and run the queries given they are remittance or claims
  289. @TODO:
  290. - make sure the readers of the queries are configurable i.e use data-transport
  291. """
  292. def __init__(self,path) :
  293. """
  294. Loading configuration file from a designated location ...
  295. """
  296. f = open(path) ;
  297. _config = json.loads(f.read())
  298. self.store_config = _config['store']
  299. self.info = _config['analytics']
  300. _args = self.store_config
  301. if self.store_config['type'] == 'mongo.MongoWriter' :
  302. _args['type'] = 'mongo.MongoReader'
  303. else:
  304. _args['type'] = 'disk.SQLiteReader'
  305. self.reader = transport.factory.instance(**_args)
  306. def apply (self,**args) :
  307. """
  308. type: claims or remits
  309. filter optional identifier claims, procedures, taxonomy, ...
  310. """
  311. _m = {'claim':'837','claims':'837','remits':'835','remit':'835'}
  312. # key = '837' if args['type'] == 'claims' else '835'
  313. table = _m[ args['type']]
  314. analytics = self.info[table]
  315. if 'index' in args :
  316. index = int(args['index'])
  317. analytics = [analytics[index]]
  318. _info = list(analytics) if 'filter' not in args else [item for item in analytics if args['filter'] == item['id']]
  319. # conn = lite.connect(self.store_config['args']['path'],isolation_level=None)
  320. # conn.create_aggregate("stdev",1,stdev)
  321. DB_TYPE = 'mongo' if (type(self.reader) == transport.mongo.MongoReader) else 'sql'
  322. r = []
  323. for row in _info :
  324. for item in row['pipeline'] :
  325. # item['data'] = pd.read_sql(item['sql'],conn)
  326. query = {DB_TYPE:item[DB_TYPE]}
  327. item['data'] = self.reader.read(**item)
  328. if 'serialize' in args :
  329. item['data'] = json.dumps(item['data'].to_dict(orient='record')) if type(item['data']) == pd.DataFrame else item['data']
  330. else:
  331. item['data'] = (pd.DataFrame(item['data']))
  332. # if 'info' in item:
  333. # item['info'] = item['info'].replace(":rows",str(item["data"].shape[0]))
  334. # conn.close()
  335. return _info
  336. def _html(self,item) :
  337. figure = None
  338. df = item['data']
  339. label = ['<div class="label">',item['label'],'</div>']
  340. text = ['<div class="grid">',df.describe().iloc[:].round(2).to_html().replace('_',' '),'</div>']
  341. info = ['<div class="info">',item['info'],'</div>'] if 'info' in item else []
  342. if item['chart']['type'] in ['pie','donut','doughnut'] :
  343. figure = Chart.donut(item)
  344. text = ['<div class="grid">',df.to_html(index=False).replace('_',' '),'</div>']
  345. elif item['chart']['type'] == 'scatter' :
  346. figure = Chart.scatter(item)
  347. elif item['chart']['type'] == 'spline' :
  348. figure = Chart.spline(item)
  349. elif item['chart']['type'] in ['barh','hbar'] :
  350. figure = Chart.barh(item)
  351. elif item['chart']['type'] == 'scalar' :
  352. figure = (item['data'].apply(lambda col: '<div class="scalar"><div class="value bold">'+str(col.values[0].round(2))+'</div><div class="value-text">'+col.name.replace('_', ' ')+'</div></div>' ).tolist())
  353. label = text = []
  354. pass
  355. if figure and item['chart']['type'] != 'scalar':
  356. stream = io.BytesIO()
  357. figure.savefig(stream,format='png',dpi=300,quality=95, bbox_inches = "tight",transparent=True)
  358. stream.seek(0)
  359. stream = base64.b64encode(stream.getvalue()).decode("utf-8")
  360. stream = "data:image/png;base64,"+stream
  361. figure = ['<div class="figure"><img src="'+stream+'">',"</div>"]
  362. # figure.canvas.draw()
  363. # figure = "".join( map(chr,figure.canvas.tostring_argb())) #--bytes
  364. # else:
  365. # figure = [ ]
  366. if item['chart']['type'] != 'scalar':
  367. return ['<div class="frame"><div class="chart '+ item['chart']['type']+'">'] + [ " ".join(row) for row in [label,figure,text,info] if row] + ["</div></div>"]
  368. else:
  369. return [ " ".join(row) for row in [label,figure,text,info] if row]
  370. pass
  371. def _csv(self,item):
  372. pass
  373. def export(self,item,format):
  374. """
  375. We have a pipeline here and we should attempt to build a figure using seaborn within an html template using jinja2
  376. This is considered a page (or an item) of an analysis where we will have both data and rendering information with accompanying text
  377. """
  378. html = []
  379. for row in item['pipeline'] :
  380. p = [ "<h2>",row['label'].replace('_',' '),"</h2>"]
  381. y_label = [name for name in row['data'].columns if 'count' in name]
  382. x_label = list(set(row['data'].columns) - set(y_label))
  383. N = row.shape[0]
  384. if 'info' in row :
  385. p += ["<div class='info'>",row['info'],'</div>']
  386. pass
  387. class LogAnalytics :
  388. def __init__(self,path):
  389. logs = open(path).read().split('\n')
  390. logs = [json.loads(row) for row in logs if row.strip() != '']
  391. self.remits = {
  392. "completed": np.sum([1 for row in logs if row['completed'] == True]),
  393. "files":len(logs)
  394. }
  395. # m = LogAnalytics('/home/steve/healthcare-io/remits.log')
  396. css = """
  397. <meta charset="utf-8">
  398. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  399. <title>HealthcareIO - :title </title>
  400. <style>
  401. body{
  402. padding:8px;
  403. padding-left:4%;
  404. padding-right:4%;
  405. }
  406. .pane{
  407. padding:4px;
  408. display:grid;
  409. gap:16px;
  410. grid-template-columns:repeat(2,1fr) ;
  411. }
  412. .numbers {
  413. display:grid;
  414. grid-template-columns:repeat(2,1fr);
  415. gap:16px;
  416. /*padding:2px;*/
  417. /*border:1px solid #CAD5E0;*/
  418. }
  419. .numbers .scalar {
  420. padding:8px;
  421. background-image: linear-gradient(to bottom, #f3f3f3,#d3d3d3, #ffffff);
  422. border:1px solid #CAD5E0;
  423. font-family:sans-serif;
  424. text-transform:capitalize;
  425. text-align:right;
  426. font-size:12px;
  427. display:grid;
  428. grid-template-rows:auto 28px; gap:2px;
  429. }
  430. .numbers .scalar .value-text {
  431. border-top:1px solid #CAD5E0;
  432. padding:8px;
  433. font-weight:bold;
  434. align-items:center;
  435. font-size:14px;
  436. display:grid;
  437. }
  438. .numbers .scalar .value {
  439. display:grid;
  440. color:#004b79;
  441. align-content:center;
  442. font-size:48px; text-align:right; font-weight:bold;}
  443. .frame {
  444. background-image: linear-gradient(to bottom, #f3f3f3,#d3d3d3, #ffffff);
  445. padding:2px;
  446. border:1px solid #CAD5E0;
  447. }
  448. .figure {grid-area:figure; width:500px; height:350px; display:grid; align-items:center}
  449. .info {height:28px; width:100%; grid-area:info;
  450. display:grid;
  451. align-items:center;
  452. text-align:center; text-transform:capitalize; padding:4px; font-size:12px; font-family:sans-serif; border-top:1px solid #CAD5E0;}
  453. .grid {grid-area:grid; }
  454. .label {grid-area:label; font-weight:bold; font-size: 22px; text-align:center; text-transform:capitalize}
  455. .chart {
  456. padding:4px;
  457. padding:8px;
  458. display:grid; grid-template-areas:
  459. "label label label"
  460. "figure grid grid"
  461. "info info info" ;
  462. gap:2px;
  463. }
  464. img {height:auto; max-width:100% ;}
  465. table {width:100%; border-collapse: collapse;}
  466. table , TH, TD{ font-size:14px; padding:8px; font-family:sans-serif; border:1px; border:1px solid #CAD5E0;}
  467. table thead, tbody th { padding:4px; text-transform:capitalize; background-color:#4682B4; color:#ffffff; text-align:center}
  468. table thead tr th {text-align:center}
  469. table tbody td {text-align:right; font-weight: lighter}
  470. table tbody tr:nth-child(odd) {background: #95bce0}
  471. table tbody tr:nth-child(even) {background: #c8e5ff}
  472. </style>
  473. """
  474. # folder = '/home/steve/.healthcareio/config.json'
  475. # e = engine(path=folder)
  476. # p = e.apply(type='claims')
  477. # values = []
  478. # html = [css]
  479. # for row in p :
  480. # frame = []
  481. # for item in row['pipeline'] :
  482. # if row['pipeline'].index(item) == 0 :
  483. # if item['chart']['type'] != 'scalar' :
  484. # # frame = ['<div class="frame">']
  485. # pass
  486. # else:
  487. # frame = ['<div><div class="numbers">']
  488. # frame += e._html(item) #p[3]['pipeline'][0])
  489. # frame += ['</div></div>'] if item['chart']['type'] == 'scalar' else []
  490. # html += frame
  491. # html = '<div class="pane">' + "\n".join(html) + "</div></div>"
  492. # f = open('out.html','w')
  493. # f.write(html.replace(":title","Claims"))
  494. #
  495. # HTML(string=html).write_pdf('out.pdf',stylesheets=[CSS(string=css)])
  496. # x.write_pdf('./out.pdf')
  497. # print (p[2]['pipeline'][0]['data'])
  498. # e.export (p[0])
  499. # features = ['diagnosis.code']
  500. # split(folder = folder, features=features)