Skip to content
This repository has been archived by the owner on Jan 9, 2024. It is now read-only.

Commit

Permalink
AutoIntent Resolving code update. (#202)
Browse files Browse the repository at this point in the history
  • Loading branch information
jzhang-gp committed Jan 16, 2020
1 parent 0e5773d commit 329137f
Showing 1 changed file with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,15 @@ def __init__(
Raises:
FileNotFoundError -- If `components_path` file does not exist.
TypeError -- If `raw` is not a pd.DataFrame.
ValueError -- When `raw` is empty
ValueError -- When any columns `raw` contain only NaNs.
"""
if not Path(components_path).is_file():
raise FileNotFoundError
if not isinstance(raw, pd.DataFrame):
raise TypeError("`raw` must be a pd.DataFrame.")
self.__check_data(raw)

self.parser = DataFrameDataSetParser(raw)
self.components_path = Path(components_path)
Expand Down Expand Up @@ -96,6 +99,27 @@ def __initialise_parser(self) -> None:
self.parser.featurize_base()
self.parser.featurize_secondary()

@staticmethod
def __check_data(df: pd.DataFrame) -> None:
"""Check quality of dataframe.
Raises:
ValueError: When `df` is empty
ValueError: When any columns `df` contain only NaNs.
"""
# Check for empty dataframe
if not len(df):
raise ValueError(
f"Dataframe with columns {df.columns.tolist()} is " "empty."
)

# Check for null columns
null_columns = df.isnull().all(axis=0)
if null_columns.any():
raise ValueError(
f"Columns {null_columns[null_columns].index.tolist()} "
"contain only NaNs."
)

def predict(
self,
threshold: Union[float, Dict[str, float]] = 0.6,
Expand Down

0 comments on commit 329137f

Please sign in to comment.