1
$\begingroup$

I'm working on a bigger school project, trying to classify timeseries measurements with Minirocket/Rocket. My trainingdata consists of a 1D matrix containing the measurements, and a seperate 1D matrix containing the corresponding labels (0/1). The matrices are equal length, so there is a label for each measurement value. I tried to run the program, which worked with other sample data, but I always receive the following error: "ValueError: Found input variables with inconsistent numbers of samples: [1, 321408]". What am I doing wrong here? Do I have to format the training data differently or are there any other settings for MiniRocket which I have to adapt as well?

This is the code that I tried running so far:

import pandas as pd
from sklearn.metrics import classification_report
from sktime.transformations.panel.rocket import MiniRocket
from sklearn.linear_model import RidgeClassifierCV
import numpy as np

# Load the data
def load_data(file_path):
    data = pd.read_csv(file_path)
    X = data['sensor_values_final'].values
    y = data['labels'].values
    assert len(X) == len(y), "Length of X and y do not match"
    return X, y

train_x, train_y = load_data(r'csv\TrainingData_2024-05-18_18-21-46_train.csv')
test_x, test_y = load_data(r'csv\TrainingData_2024-05-18_18-21-46_test.csv')

# Transform the data
minirocket = MiniRocket(10_000)  # by default, MiniRocket uses ~10,000 kernels
minirocket.fit(train_x)
train_x_transform = minirocket.transform(train_x)
test_x_transform = minirocket.transform(test_x)

# Train the model
classifier = RidgeClassifierCV(alphas=np.logspace(-3, 3, 10))
classifier.fit(train_x_transform, train_y)

# Evaluate the model
train_y_pred = classifier.predict(train_x_transform)
test_y_pred = classifier.predict(test_x_transform)

print("Test set performance:")
print(classification_report(test_y, test_y_pred))
$\endgroup$
1
  • $\begingroup$ It's great that you provide your python code. However, without the data this is not a minimal reproducible example. Moreover, purely programming questions are off-topic on Cross Validated, so I vote to migrate this question to Stack Overflow. $\endgroup$ Commented May 19, 2024 at 12:19

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.