How to use Sklearn train test split function for nested dataframes or multi-indexed datafames?

Viewed 77

I am trying to implement functions from sktime, but with my own data.

I have formatted my data into a multi-indexed dataframe, and sktime supports converting that into a nested dataframe.

for sku in sku_list:
    temp_df = single_query(sku)
    temp_df.insert(0, "sku", sku)
    master_df = pandas.concat([temp_df, master_df], ignore_index=True)

master_df.set_index(["sku", "date"], inplace=True)

df_nested = from_multi_index_to_nested(master_df, instance_index="sku")

I would now like to use that data with sktime's multivariate time series classification.

My multi-indexed dataframe looks something like this:

sku date units_ordered sessions conversion_rate
A1 3-1-21 2 20 10
3-2-21 2 20 10
3-3-21 2 20 10
3-4-21 2 20 10

I have a table populated like this for about 40 SKUs.

Sktime's documentation does not have any examples of how I could take a dataset from this stage to the X and Y values for the train test split.

I appreciate any guidance.

0 Answers
Related