ibis-ml
ibis-ml copied to clipboard
feat: enable not fitted check for transform_table() and throw proper exception
The current transform_table throws AttributeError when step is not fitted.
import ibisml as ml
t = ibis.memtable({"a": [1, 2, 3], "b": [2,3,4], "c": [3,4,5]})
step = ml.CountEncode(ml.string())
step.transform_table(t)
----> 1 step.transform_table(t)
File /Users/voltrondata/repos/ibisml/ibisml/steps/encode.py:281, in CountEncode.transform_table(self, table)
280 def transform_table(self, table: ir.Table) -> ir.Table:
--> 281 for c, value_counts in self.value_counts_.items():
282 joined = table.left_join(
283 value_counts, table[c] == value_counts[0], lname="left_{name}", rname=""
284 )
285 table = joined.drop(value_counts.columns[0], f"left_{c}").rename(
286 {c: f"{c}_count"}
287 )
AttributeError: 'CountEncode' object has no attribute 'value_counts_'
Desired output
Ensure step is fitted when transform_table, otherwise throws proper error, such as NotFitError
Does this also happen when used as part of a scikit-learn pipeline? If not, this may be slightly lower priority.
Putting as P2 for now; feel free to increase to P1 or higher if it does happen in scikit-learn pipeline, too.