Skip to content

Commit 4d9bf43

Browse files
committed
Revert "Removing get_sample_df to remove pandas, considered a too heavy addition."
This reverts commit d77cbad.
1 parent d77cbad commit 4d9bf43

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

dataikuapi/dss/modelevaluationstore.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
import json
2+
from io import BytesIO
3+
4+
import pandas as pd
25

36
from dataikuapi.dss.metrics import ComputedMetrics
47
from .discussion import DSSObjectDiscussions
@@ -294,6 +297,26 @@ def get_metrics(self):
294297
return self.client._perform_json(
295298
"GET", "/projects/%s/modelevaluationstores/%s/runs/%s/metrics" % (self.project_key, self.mes_id, self.run_id))
296299

300+
def get_sample_df(self):
301+
"""
302+
Get the sample of the evaluation dataset on which the evaluation was performed
303+
304+
:return:
305+
the sample content, as a :class:`pandas.DataFrame`
306+
"""
307+
buf = BytesIO()
308+
with self.client._perform_raw(
309+
"GET",
310+
"/projects/%s/modelevaluationstores/%s/runs/%s/sample" % (self.project_key, self.mes_id, self.run_id)
311+
).raw as f:
312+
buf.write(f.read())
313+
schema_txt = self.client._perform_raw(
314+
"GET",
315+
"/projects/%s/modelevaluationstores/%s/runs/%s/schema" % (self.project_key, self.mes_id, self.run_id)
316+
).text
317+
schema = json.loads(schema_txt)
318+
return pd.read_csv(BytesIO(buf.getvalue()), compression='gzip', sep='\t', header=None, names=[c["name"] for c in schema["columns"]])
319+
297320

298321
class DSSModelEvaluationFullInfo:
299322
"""

0 commit comments

Comments
 (0)