• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

WenjieDu / PyPOTS / 4649236213

pending completion
4649236213

Pull #44

github

GitHub
Merge 0b894402b into 4646f5c3f
Pull Request #44: Make imputation models `val_X_intact` and `val_indicating_mask` be included in input `val_set` originally

15 of 15 new or added lines in 6 files covered. (100.0%)

2694 of 3170 relevant lines covered (84.98%)

0.85 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

17.65
/pypots/data/load_preprocessing.py
1
"""
1✔
2
Preprocessing functions to load supported open-source time-series datasets.
3
"""
4

5
# Created by Wenjie Du <wenjay.du@gmail.com>
6
# License: GLP-v3
7

8
import pandas as pd
1✔
9

10

11
def preprocess_physionet2012(data: dict) -> dict:
1✔
12
    """The preprocessing function for dataset PhysioNet-2012.
13

14
    Parameters
15
    ----------
16
    data : dict,
17
        A data dict from tsdb.load_dataset().
18

19
    Returns
20
    -------
21
    dataset : dict,
22
        A dict containing processed data, including:
23
            X : pandas.DataFrame,
24
                A dataframe contains all time series vectors from 11988 patients, distinguished by column `RecordID`.
25
            y : pandas.Series
26
                The 11988 classification labels of all patients, indicating whether they were deceased.
27
    """
28
    # remove the static features, e.g. age, gender
29
    X = data["X"].drop(data["static_features"], axis=1)
×
30

31
    def apply_func(df_temp):  # pad and truncate to set the max length of samples as 48
×
32
        missing = list(set(range(0, 48)).difference(set(df_temp["Time"])))
×
33
        missing_part = pd.DataFrame({"Time": missing})
×
34
        df_temp = pd.concat(
×
35
            [df_temp, missing_part], ignore_index=False, sort=False
36
        )  # pad the sample's length to 48 if it doesn't have enough time steps
37
        df_temp = df_temp.set_index("Time").sort_index().reset_index()
×
38
        df_temp = df_temp.iloc[:48]  # truncate
×
39
        return df_temp
×
40

41
    X = X.groupby("RecordID").apply(apply_func)
×
42
    X = X.drop("RecordID", axis=1)
×
43
    X = X.reset_index()
×
44
    X = X.drop(["level_1", "Time"], axis=1)
×
45

46
    dataset = {
×
47
        "X": X,
48
        "y": data["y"],
49
    }
50

51
    return dataset
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc