Problems with custom dataset using Minirocket classification

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?

The error is triggered by the following line of code: classifier.fit(train_x_transform, train_y)

This is the full code that I tried running so far:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>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'csvTrainingData_2024-05-18_18-21-46_train.csv')
test_x, test_y = load_data(r'csvTrainingData_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))
</code>
<code>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'csvTrainingData_2024-05-18_18-21-46_train.csv') test_x, test_y = load_data(r'csvTrainingData_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)) </code>
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'csvTrainingData_2024-05-18_18-21-46_train.csv')
test_x, test_y = load_data(r'csvTrainingData_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))

New contributor

Michael is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật