Skip to content

Commit

Permalink
Fix optional model in tabular tasks (#2018)
Browse files Browse the repository at this point in the history
* Fix optional model in tabular tasks

* Apply suggestions from code review

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* make style

---------

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
  • Loading branch information
Wauplin and abidlabs authored Feb 7, 2024
1 parent 5433ea9 commit 400697c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
18 changes: 10 additions & 8 deletions src/huggingface_hub/inference/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1063,16 +1063,17 @@ def table_question_answering(
)
return _bytes_to_dict(response) # type: ignore

def tabular_classification(self, table: Dict[str, Any], *, model: str) -> List[str]:
def tabular_classification(self, table: Dict[str, Any], *, model: Optional[str] = None) -> List[str]:
"""
Classifying a target category (a group) based on a set of attributes.
Args:
table (`Dict[str, Any]`):
Set of attributes to classify.
model (`str`):
The model to use for the tabular-classification task. Can be a model ID hosted on the Hugging Face Hub or a URL to
a deployed Inference Endpoint.
model (`str`, *optional*):
The model to use for the tabular classification task. Can be a model ID hosted on the Hugging Face Hub or a URL to
a deployed Inference Endpoint. If not provided, the default recommended tabular classification model will be used.
Defaults to None.
Returns:
`List`: a list of labels, one per row in the initial table.
Expand Down Expand Up @@ -1107,16 +1108,17 @@ def tabular_classification(self, table: Dict[str, Any], *, model: str) -> List[s
response = self.post(json={"table": table}, model=model, task="tabular-classification")
return _bytes_to_list(response)

def tabular_regression(self, table: Dict[str, Any], *, model: str) -> List[float]:
def tabular_regression(self, table: Dict[str, Any], *, model: Optional[str] = None) -> List[float]:
"""
Predicting a numerical target value given a set of attributes/features in a table.
Args:
table (`Dict[str, Any]`):
Set of attributes stored in a table. The attributes used to predict the target can be both numerical and categorical.
model (`str`):
The model to use for the tabular-regression task. Can be a model ID hosted on the Hugging Face Hub or a URL to
a deployed Inference Endpoint.
model (`str`, *optional*):
The model to use for the tabular regression task. Can be a model ID hosted on the Hugging Face Hub or a URL to
a deployed Inference Endpoint. If not provided, the default recommended tabular regression model will be used.
Defaults to None.
Returns:
`List`: a list of predicted numerical target values.
Expand Down
18 changes: 10 additions & 8 deletions src/huggingface_hub/inference/_generated/_async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1080,16 +1080,17 @@ async def table_question_answering(
)
return _bytes_to_dict(response) # type: ignore

async def tabular_classification(self, table: Dict[str, Any], *, model: str) -> List[str]:
async def tabular_classification(self, table: Dict[str, Any], *, model: Optional[str] = None) -> List[str]:
"""
Classifying a target category (a group) based on a set of attributes.
Args:
table (`Dict[str, Any]`):
Set of attributes to classify.
model (`str`):
The model to use for the tabular-classification task. Can be a model ID hosted on the Hugging Face Hub or a URL to
a deployed Inference Endpoint.
model (`str`, *optional*):
The model to use for the tabular classification task. Can be a model ID hosted on the Hugging Face Hub or a URL to
a deployed Inference Endpoint. If not provided, the default recommended tabular classification model will be used.
Defaults to None.
Returns:
`List`: a list of labels, one per row in the initial table.
Expand Down Expand Up @@ -1125,16 +1126,17 @@ async def tabular_classification(self, table: Dict[str, Any], *, model: str) ->
response = await self.post(json={"table": table}, model=model, task="tabular-classification")
return _bytes_to_list(response)

async def tabular_regression(self, table: Dict[str, Any], *, model: str) -> List[float]:
async def tabular_regression(self, table: Dict[str, Any], *, model: Optional[str] = None) -> List[float]:
"""
Predicting a numerical target value given a set of attributes/features in a table.
Args:
table (`Dict[str, Any]`):
Set of attributes stored in a table. The attributes used to predict the target can be both numerical and categorical.
model (`str`):
The model to use for the tabular-regression task. Can be a model ID hosted on the Hugging Face Hub or a URL to
a deployed Inference Endpoint.
model (`str`, *optional*):
The model to use for the tabular regression task. Can be a model ID hosted on the Hugging Face Hub or a URL to
a deployed Inference Endpoint. If not provided, the default recommended tabular regression model will be used.
Defaults to None.
Returns:
`List`: a list of predicted numerical target values.
Expand Down

0 comments on commit 400697c

Please sign in to comment.