Skip to content

feat: enable not fitted check for transform_table() and throw proper exception #52

Open
@jitingxu1

Description

@jitingxu1

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

backlog

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions