From 6a3a649f1dcfbbd531c630c32ff3821018988504 Mon Sep 17 00:00:00 2001 From: "Arun S. Maiya" Date: Fri, 14 Jun 2024 18:13:47 -0400 Subject: [PATCH] changes for test_dataloading warnings --- ktrain/text/data.py | 4 ++-- ktrain/text/ner/preprocessor.py | 8 +++++--- ktrain/vision/data.py | 4 ++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/ktrain/text/data.py b/ktrain/text/data.py index 8cfaeb85b..c03665b32 100644 --- a/ktrain/text/data.py +++ b/ktrain/text/data.py @@ -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 diff --git a/ktrain/text/ner/preprocessor.py b/ktrain/text/ner/preprocessor.py index b4f997ffd..1d7a86bb0 100644 --- a/ktrain/text/ner/preprocessor.py +++ b/ktrain/text/ner/preprocessor.py @@ -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 @@ -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): diff --git a/ktrain/vision/data.py b/ktrain/vision/data.py index b163233d0..ee211f998 100644 --- a/ktrain/vision/data.py +++ b/ktrain/vision/data.py @@ -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, @@ -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,