马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
本帖最后由 125404629 于 2023-10-10 17:40 编辑
求助大神!
深度学习MiniRocket 报错! QQ8065559062,如能解决必有重谢
发生异常: ZeroDivisionError
division by zero
File "D:\0000可见光2\程序\MiniRocket\from sktime.transformations.panel.py", line 20, in <module>
X_train_trans = minirocket.fit_transform(X_train)
ZeroDivisionError: division by zero
数据请联系QQ
import numpy as np
import pandas as pd
from keras.utils import to_categorical
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import accuracy_score
from sktime.transformations.panel.rocket import MiniRocketMultivariate
df1 = pd.read_csv("train1.csv")
df1 = np.array(df1)
X = df1[:, 1:891] # 对数据进行增维并转化为32为
Y = df1[:, 0]
print(X.shape, Y.shape)
X_train, X_val, y_train, y_val = train_test_split(X, Y, test_size=0.8, random_state=42)
# Apply MINIROCKET transformation (feature extraction) to train and test data
minirocket = MiniRocketMultivariate(num_kernels=10, random_state=42)
#minirocket = MiniRocket()
X_train_trans = minirocket.fit_transform(X_train)
X_val_trans= minirocket.fit_transform(X_val)
print(X_train_trans.shape, X_val_trans.shape)
print(2)
# Train a linear classifier (Logistic Regression) on the transformed training data
classifier = LogisticRegression(max_iter=1000, random_state=42)
classifier.fit(X_train_trans, y_train)
print(3)
y_train_pre = classifier.predict_proba(X_train_trans)
accuracy_cal = accuracy_score(y_train, y_train_pre)
print(f'Calibration Accuracy: {accuracy_cal * 100:.2f}%')
print(4)
|