Skip to content

Commit

Permalink
changes for test_dataloading warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
amaiya committed Jun 14, 2024
1 parent 2b1a580 commit 6a3a649
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions ktrain/text/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,10 +292,10 @@ def texts_from_df(

# read in train and test data
train_df = train_df.copy()
train_df[text_column].fillna("fillna", inplace=True)
train_df[text_column] = train_df[text_column].fillna("fillna")
if val_df is not None:
val_df = val_df.copy()
val_df[text_column].fillna("fillna", inplace=True)
val_df[text_column] = val_df[text_column].fillna("fillna")
else:
train_df, val_df = train_test_split(
train_df, test_size=val_pct, random_state=random_state
Expand Down
8 changes: 5 additions & 3 deletions ktrain/text/ner/preprocessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,13 @@ def conll2003_to_df(filepath, encoding="latin1"):
if not docstart:
sent_id += 1
df = pd.DataFrame({SENT_COL: sents, WORD_COL: words, TAG_COL: tags})
df = df.fillna(method="ffill")
df = df.ffill()
return df


def gmb_to_df(filepath, encoding="latin1"):
df = pd.read_csv(filepath, encoding=encoding)
df = df.fillna(method="ffill")
df = df.ffill()
return df


Expand Down Expand Up @@ -234,7 +234,9 @@ def __init__(self, data, word_column, tag_column, sentence_column):
s[word_column].values.tolist(), s[tag_column].values.tolist()
)
]
self.grouped = self.data.groupby(sentence_column).apply(agg_func)
self.grouped = self.data.groupby(sentence_column).apply(
agg_func, include_groups=False
)
self.sentences = [s for s in self.grouped]

def get_next(self):
Expand Down
4 changes: 2 additions & 2 deletions ktrain/vision/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ def images_from_df(
x_col=image_column,
y_col=label_columns,
target_size=target_size,
class_mode="other",
class_mode="raw",
shuffle=True,
interpolation="bicubic",
color_mode=color_mode,
Expand All @@ -611,7 +611,7 @@ def images_from_df(
x_col=image_column,
y_col=label_columns,
target_size=target_size,
class_mode="other",
class_mode="raw",
shuffle=False,
interpolation="bicubic",
color_mode=color_mode,
Expand Down

0 comments on commit 6a3a649

Please sign in to comment.