tsai icon indicating copy to clipboard operation
tsai copied to clipboard

Dilation greater than zero

Open Yurnerosk opened this issue 1 year ago • 2 comments

I have a time series dataframe containing 80 features, 29922 rows, and the idea was to first use MINIROCKET for feature creation, and then use a linear regressor to reconstruct a target column. I'm doing:

import pandas as pd
import torch
from tsai.models.MINIROCKET_Pytorch import *
from sklearn.linear_model import LinearRegression  # You can choose another regressor
from sklearn.metrics import mean_squared_error
from sklearn.model_selection import train_test_split

...


X = df.drop(columns=[target_column]).values  # Feature matrix (80 columns - target)
y = df[target_column].values  # Target vector

# Step 2: Split the data into training and testing sets
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

# Step 3: Initialize and fit MiniRocket
num_samples, num_features = X_train.shape
time_steps = 1  # Assuming you have 1 time step

# Reshape to 3D format
X_train_reshaped = X_train.reshape(num_samples, time_steps, num_features)
X_test_reshaped = X_test.reshape(X_test.shape[0], time_steps, num_features)

To finally:

# Initialize MiniRocket
mrf = MiniRocketFeatures(num_features, time_steps).to(torch.device('cpu'))
mrf.fit(X_train_reshaped)

However, it seems that the dilation cannot be greater than 1.

---> [74](file:///C:/Users.../.venv/Lib/site-packages/tsai/models/MINIROCKET_Pytorch.py:74) C = F.conv1d(x, self.kernels, padding=padding, dilation=dilation, groups=self.c_in)
     [75](file:///C:/Users.../.venv/Lib/site-packages/tsai/models/MINIROCKET_Pytorch.py:75) if self.c_in > 1: # multivariate
     [76](file:///C:/Users.../.venv/Lib/site-packages/tsai/models/MINIROCKET_Pytorch.py:76)     C = C.reshape(x.shape[0], self.c_in, self.num_kernels, -1)

RuntimeError: dilation should be greater than zero

What should I do?

Python 3.12.2 Windows 10 tsai 0.3.9 torch 2.2.2

Yurnerosk avatar Sep 24 '24 23:09 Yurnerosk