Я использую ADTK для обнаружения аномалий и matplotlib для визуализации, но получаю ошибки при попытке запустить программу. Это мой код, и я использую Python3
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
from adtk.data import validate_series
from adtk.visualization import plot
from adtk.detector import PersistAD
data = pd.read_csv('SQL_bytes_sent_ferdig.csv', index_col="time", parse_dates=True)
# Convert the index to a DatetimeIndex explicitly if it's not already
data.index = pd.to_datetime(data.index, utc=True)
# Add 1 hour to the index
data.index = data.index + pd.Timedelta(hours=1)
data_valid = validate_series(data)
persist_ad = PersistAD(c=3.0, side='positive')
anomalies = persist_ad.fit_detect(data_valid)
plot(data_valid, anomaly=anomalies, ts_linewidth=1, ts_markersize=3, anomaly_markersize=3, anomaly_color='red', anomaly_tag="marker");
При выполнении этой команды возникает следующая ошибка:
/home/ubuntu/ad/sql_ad.py:1: DeprecationWarning:
Pyarrow will become a required dependency of pandas in the next major release of pandas (pandas 3.0),
(to allow more performant data types, such as the Arrow string type, and better interoperability with other libraries)
but was not found to be installed on your system.
If this would cause problems for you,
please provide us feedback at https://github.com/pandas-dev/pandas/issues/54466
import pandas as pd
/home/ubuntu/.local/lib/python3.10/site-packages/adtk/detector/_detector_1d.py:270: FutureWarning: Setting an item of incompatible dtype is deprecated and will raise an error in a future version of pandas. Value 'nan' has dtype incompatible with bool, please explicitly cast to a compatible dtype first.
predicted[s.isna()] = np.nan
/home/ubuntu/.local/lib/python3.10/site-packages/adtk/detector/_detector_1d.py:141: FutureWarning: Setting an item of incompatible dtype is deprecated and will raise an error in a future version of pandas. Value 'nan' has dtype incompatible with bool, please explicitly cast to a compatible dtype first.
predicted[s.isna()] = np.nan
/home/ubuntu/.local/lib/python3.10/site-packages/adtk/aggregator/_aggregator.py:211: FutureWarning: Setting an item of incompatible dtype is deprecated and will raise an error in a future version of pandas. Value 'nan' has dtype incompatible with bool, please explicitly cast to a compatible dtype first.
predicted[predicted & lists.isna().any(axis=1)] = float("nan")
Traceback (most recent call last):
File "/home/ubuntu/.local/lib/python3.10/site-packages/matplotlib/style/core.py", line 137, in use
style = _rc_params_in_file(style)
File "/home/ubuntu/.local/lib/python3.10/site-packages/matplotlib/__init__.py", line 866, in _rc_params_in_file
with _open_file_or_url(fname) as fd:
File "/usr/lib/python3.10/contextlib.py", line 135, in __enter__
return next(self.gen)
File "/home/ubuntu/.local/lib/python3.10/site-packages/matplotlib/__init__.py", line 843, in _open_file_or_url
with open(fname, encoding='utf-8') as f:
FileNotFoundError: [Errno 2] No such file or directory: 'seaborn-whitegrid'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/ubuntu/ad/sql_ad.py", line 22, in
plot(data_valid, anomaly=anomalies, ts_linewidth=1, ts_markersize=3, anomaly_markersize=3, anomaly_color='red', anomaly_tag="marker");
File "/home/ubuntu/.local/lib/python3.10/site-packages/adtk/visualization/_visualization.py", line 201, in plot
plt.style.use("seaborn-whitegrid")
File "/home/ubuntu/.local/lib/python3.10/site-packages/matplotlib/style/core.py", line 139, in use
raise OSError(
OSError: 'seaborn-whitegrid' is not a valid package style, path of style file, URL of style file, or library style name (library styles are listed in `style.available`)
Я просмотрел другие сообщения с похожими проблемами и попытался указать, какой стиль использовать в моем коде, где у меня есть следующие стили:
Но ни один из них не меняет ошибку. Запустив его в Jupytor Notebook, он работает, и мне даже не нужно указывать, какой график использовать. Я попробовал установить seaborn с помощью pip, но ничего не помогло.
Я использую ADTK для обнаружения аномалий и matplotlib для визуализации, но получаю ошибки при попытке запустить программу. Это мой код, и я использую Python3 [code]import pandas as pd import matplotlib.pyplot as plt import matplotlib.dates as mdates
from adtk.data import validate_series from adtk.visualization import plot from adtk.detector import PersistAD
data = pd.read_csv('SQL_bytes_sent_ferdig.csv', index_col="time", parse_dates=True) # Convert the index to a DatetimeIndex explicitly if it's not already data.index = pd.to_datetime(data.index, utc=True)
# Add 1 hour to the index data.index = data.index + pd.Timedelta(hours=1) data_valid = validate_series(data)
plot(data_valid, anomaly=anomalies, ts_linewidth=1, ts_markersize=3, anomaly_markersize=3, anomaly_color='red', anomaly_tag="marker"); [/code] При выполнении этой команды возникает следующая ошибка: [code]/home/ubuntu/ad/sql_ad.py:1: DeprecationWarning: Pyarrow will become a required dependency of pandas in the next major release of pandas (pandas 3.0), (to allow more performant data types, such as the Arrow string type, and better interoperability with other libraries) but was not found to be installed on your system. If this would cause problems for you, please provide us feedback at https://github.com/pandas-dev/pandas/issues/54466
import pandas as pd /home/ubuntu/.local/lib/python3.10/site-packages/adtk/detector/_detector_1d.py:270: FutureWarning: Setting an item of incompatible dtype is deprecated and will raise an error in a future version of pandas. Value 'nan' has dtype incompatible with bool, please explicitly cast to a compatible dtype first. predicted[s.isna()] = np.nan /home/ubuntu/.local/lib/python3.10/site-packages/adtk/detector/_detector_1d.py:141: FutureWarning: Setting an item of incompatible dtype is deprecated and will raise an error in a future version of pandas. Value 'nan' has dtype incompatible with bool, please explicitly cast to a compatible dtype first. predicted[s.isna()] = np.nan /home/ubuntu/.local/lib/python3.10/site-packages/adtk/aggregator/_aggregator.py:211: FutureWarning: Setting an item of incompatible dtype is deprecated and will raise an error in a future version of pandas. Value 'nan' has dtype incompatible with bool, please explicitly cast to a compatible dtype first. predicted[predicted & lists.isna().any(axis=1)] = float("nan") Traceback (most recent call last): File "/home/ubuntu/.local/lib/python3.10/site-packages/matplotlib/style/core.py", line 137, in use style = _rc_params_in_file(style) File "/home/ubuntu/.local/lib/python3.10/site-packages/matplotlib/__init__.py", line 866, in _rc_params_in_file with _open_file_or_url(fname) as fd: File "/usr/lib/python3.10/contextlib.py", line 135, in __enter__ return next(self.gen) File "/home/ubuntu/.local/lib/python3.10/site-packages/matplotlib/__init__.py", line 843, in _open_file_or_url with open(fname, encoding='utf-8') as f: FileNotFoundError: [Errno 2] No such file or directory: 'seaborn-whitegrid'
The above exception was the direct cause of the following exception:
Traceback (most recent call last): File "/home/ubuntu/ad/sql_ad.py", line 22, in plot(data_valid, anomaly=anomalies, ts_linewidth=1, ts_markersize=3, anomaly_markersize=3, anomaly_color='red', anomaly_tag="marker"); File "/home/ubuntu/.local/lib/python3.10/site-packages/adtk/visualization/_visualization.py", line 201, in plot plt.style.use("seaborn-whitegrid") File "/home/ubuntu/.local/lib/python3.10/site-packages/matplotlib/style/core.py", line 139, in use raise OSError( OSError: 'seaborn-whitegrid' is not a valid package style, path of style file, URL of style file, or library style name (library styles are listed in `style.available`) [/code] Я просмотрел другие сообщения с похожими проблемами и попытался указать, какой стиль использовать в моем коде, где у меня есть следующие стили: [code]import matplotlib.pyplot as plt # plt.style.use(['science', 'notebook']) print(plt.style.available) [/code] Даёт: [code]['Solarize_Light2', '_classic_test_patch', '_mpl-gallery', '_mpl-gallery-nogrid', 'bmh', 'classic', 'dark_background', 'fast', 'fivethirtyeight', 'ggplot', 'grayscale', 'seaborn-v0_8', 'seaborn-v0_8-bright', 'seaborn-v0_8-colorblind', 'seaborn-v0_8-dark', 'seaborn-v0_8-dark-palette', 'seaborn-v0_8-darkgrid', 'seaborn-v0_8-deep', 'seaborn-v0_8-muted', 'seaborn-v0_8-notebook', 'seaborn-v0_8-paper', 'seaborn-v0_8-pastel', 'seaborn-v0_8-poster', 'seaborn-v0_8-talk', 'seaborn-v0_8-ticks', 'seaborn-v0_8-white', 'seaborn-v0_8-whitegrid', 'tableau-colorblind10'] [/code] Но ни один из них не меняет ошибку. Запустив его в Jupytor Notebook, он работает, и мне даже не нужно указывать, какой график использовать. Я попробовал установить seaborn с помощью pip, но ничего не помогло.