Last active
May 13, 2022 13:05
-
-
Save peace098beat/db228630b0ad6b9e19c970962505c6d9 to your computer and use it in GitHub Desktop.
[sktime]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
print(df_long.head(3)) # longじゃない | |
sample index x y z time | |
0 2021-11-01 13:40:17.429 0 -0.912 0.369 -0.031 2021-11-01 13:40:17.429 | |
1 2021-11-01 13:40:17.429 1 -0.908 0.363 -0.039 2021-11-01 13:40:17.529 | |
2 2021-11-01 13:40:17.429 2 -0.910 0.363 -0.037 2021-11-01 13:40:17.629 | |
# sktime形式に変更 | |
# - sample(フレーム)毎に,groupbyして、行毎にシリーズに変更 | |
df_train = df_long.groupby(["sample"]).apply(lambda x: pd.Series([x["x"], x["y"], x["z"]]) ) | |
df_train |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM python:3.8-buster as builder | |
RUN pip3 install --upgrade pip | |
RUN pip3 install sktime==0.11.0 | |
FROM python:3.8-slim-buster as runner | |
COPY --from=builder /usr/local/lib/python3.8/site-packages /usr/local/lib/python3.8/site-packages | |
RUN apt-get update \ | |
&& apt-get install -y locales locales-all\ | |
&& locale-gen ja_JP.UTF-8 \ | |
&& apt install -y libxml2 libgomp1\ | |
&& apt-get clean \ | |
&& rm -rf /var/lib/apt/lists/* | |
ENV TZ Asia/Tokyo | |
ENV LANG ja_JP.UTF-8 | |
ENV LC_ALL ja_JP.UTF-8 | |
ENV LANGUAGE ja_JP.UTF-8 | |
# ---------------------------------------------------------------------------------------------- | |
ENV NUMBA_CPU_NAME=generic | |
RUN python3 -c "import sktime; print(sktime.__version__)" | |
RUN python3 -c "import sktime; from sktime.transformations.panel.rocket import MiniRocketMultivariate" | |
RUN python3 -c "import sktime; from sktime.transformations.panel.rocket import MiniRocketMultivariate" | |
ENTRYPOINT ["python3"] | |
CMD ["-m" "import sktime; from sktime.transformations.panel.rocket import MiniRocketMultivariate"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BASE_DIR = f"/content/drive/MyDrive/workspace/datasets/sktime/" | |
!mkdir -p {BASE_DIR} | |
!wget http://www.timeseriesclassification.com/Downloads/UWaveGestureLibrary.zip | |
!unzip UWaveGestureLibrary.zip -d {BASE_DIR}/UWaveGestureLibrary | |
!pip install sktime[all_extras] -qq | |
import sktime | |
print(sktime.__version__) | |
import os | |
import sktime | |
from sktime.datasets import load_from_tsfile_to_dataframe | |
DATA_PATH = BASE_DIR | |
train_x, train_y = load_from_tsfile_to_dataframe( | |
os.path.join(DATA_PATH, "UWaveGestureLibrary/UWaveGestureLibrary_TRAIN.ts") | |
) | |
test_x, test_y = load_from_tsfile_to_dataframe( | |
os.path.join(DATA_PATH, "UWaveGestureLibrary/UWaveGestureLibrary_TEST.ts") | |
) | |
from sktime.datatypes._panel._convert import from_nested_to_3d_numpy | |
X_ary = from_nested_to_3d_numpy(train_x) | |
test_x_ary = from_nested_to_3d_numpy(test_x) | |
import numpy as np | |
np.save(f"{BASE_DIR}/UWaveGestureLibrary/train_x.npy", X_ary) | |
np.save(f"{BASE_DIR}/UWaveGestureLibrary/train_y.npy", train_y) | |
np.save(f"{BASE_DIR}/UWaveGestureLibrary/test_x.npy", test_x_ary) | |
np.save(f"{BASE_DIR}/UWaveGestureLibrary/test_y.npy", test_y) | |
assert len(X_ary) == len(train_y) | |
assert len(test_x_ary) == len(test_y) | |
X_ary = np.load(f"{BASE_DIR}/UWaveGestureLibrary/train_x.npy") | |
train_y = np.load(f"{BASE_DIR}/UWaveGestureLibrary/train_y.npy") | |
test_x_ary = np.load(f"{BASE_DIR}/UWaveGestureLibrary/test_x.npy") | |
test_y = np.load(f"{BASE_DIR}/UWaveGestureLibrary/test_y.npy") | |
assert len(X_ary) == len(train_y) | |
assert len(test_x_ary) == len(test_y) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment