Я пытаюсь создать приложение для классификации данных временных рядов. Я создал функцию, которая должна проверять, содержит ли файл данные временных рядов или нет.
Я загрузил данные временных рядов со следующего веб-сайта, чтобы проверить, работает ли моя функция должным образом, но, к сожалению, этого не произошло.
Вот веб-сайт, с которого я загрузил конкретный набор данных, который использовал для тестирования. https://www.timeseriesclassification.co ... aset=ACSF1
Вот мой код, у функции is_time_series возникают проблемы, и она срабатывает, когда я нажимаю «Train Test». Обратите внимание, что функция, которая не работает должным образом, создается ChatGPT.
Вот остальная часть файла main.py. Функция выше является частью main.py
def is_time_series(self, file_path):
try:
# Assuming the file is comma-separated
df = pd.read_csv(file_path, header=None)
# Check if the data is numerical
if not all(df.dtypes.apply(lambda x: np.issubdtype(x, np.number))):
return False
# Optionally, you can add more logic here to verify time series characteristics
# For example, check if the first column is monotonic or if there are multiple columns of data.
# Since your data doesn't have explicit datetime columns, we assume it's a valid time series.
return True
except Exception as e:
print(f"Error reading file: {e}")
return False
Здесь вызывается функция
def validate_inputs(self, classifierSelection):
# Getting `train_data_entry` and `test_data_entry` from singleDataset.py
train_file = classifierSelection.train_data_entry.get()
test_file = classifierSelection.test_data_entry.get()
numRuns = classifierSelection.runEntry.get()
custom_classifier_file = classifierSelection.custom_classifier_entry.get()
if not train_file:
self.show_error("Error: Please select a training data file.")
return False
if not self.is_time_series(train_file):
self.show_error("Error: Training data file does not seem to contain valid time series data.")
return False
if not test_file:
self.show_error("Error: Please select a testing data file.")
return False
if not self.is_time_series(test_file):
self.show_error("Error: Testing data file does not seem to contain valid time series data.")
return False
if custom_classifier_file and not custom_classifier_file.endswith(".py"):
self.show_error("Error: Custom classifier file must end with '.py'.")
return False
if not self.checkRuns(numRuns):
self.show_error("Error: The number of runs cannot be less than 1 or empty")
return True
Подробнее здесь: https://stackoverflow.com/questions/790 ... -data-does