當前位置: 首頁>>代碼示例>>Python>>正文


Python utils.split_data方法代碼示例

本文整理匯總了Python中utils.split_data方法的典型用法代碼示例。如果您正苦於以下問題:Python utils.split_data方法的具體用法?Python utils.split_data怎麽用?Python utils.split_data使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在utils的用法示例。


在下文中一共展示了utils.split_data方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: load_dataset

# 需要導入模塊: import utils [as 別名]
# 或者: from utils import split_data [as 別名]
def load_dataset(cfg):
    length_std  = float(cfg['length_std'])
    length_mean = float(cfg['length_mean'])
    noise_std   = float(cfg['noise_std'])
    length      = int(cfg['length'])
    nb_past_steps   = int(cfg['nb_past_steps'])
    nb_future_steps = int(cfg['nb_future_steps'])
    train_fraction  = float(cfg['train_fraction'])
    test_fraction   = float(cfg['test_fraction'])
    valid_fraction  = float(cfg['valid_fraction'])

    sequence = generate_sequence(length_std, length_mean, noise_std, length)

    xs, ys = utils.sequence_to_supervised(sequence, nb_past_steps, nb_future_steps)
    xs = np.expand_dims(xs, axis=2)
    ys = np.expand_dims(ys, axis=1)

    x_train, x_valid, x_test = utils.split_data(xs, train_fraction,
            valid_fraction, test_fraction)

    y_train, y_valid, y_test = utils.split_data(ys, train_fraction,
            valid_fraction, test_fraction)

    return x_train, y_train, x_valid, y_valid, x_test, y_test 
開發者ID:johnmartinsson,項目名稱:blood-glucose-prediction,代碼行數:26,代碼來源:normal_experiment.py

示例2: find_opt_seq_len

# 需要導入模塊: import utils [as 別名]
# 或者: from utils import split_data [as 別名]
def find_opt_seq_len(self, validation, update=True):
        # Finds minimal seq length s.t accuracy=1 on all sessions
        opt_seq_len = 1
        # Find minimal sequence length s.t FPR=1 for all other devs
        for dev_name, dev_sessions in validation.groupby('device_category'):
            dev_sessions = utils.split_data(dev_sessions, y_col=self.y_col)[0]
            is_dev = self.is_dev(dev_name)
            start = 0
            seq_len = 1
            while start + seq_len < len(dev_sessions):
                is_dev_pred = (self.predict([dev_sessions[start:start + seq_len]]))[0]
                if is_dev == is_dev_pred:
                    start += 1
                else:
                    start = max(1, start-2)
                    seq_len += 2
            opt_seq_len = max(seq_len, opt_seq_len)
        # Return minimal seq length s.t accuracy=1
        if update:
            self.opt_seq_len = opt_seq_len
        return opt_seq_len 
開發者ID:Mosseridan,項目名稱:IoT-device-type-identification,代碼行數:23,代碼來源:device_sequence_classifier.py

示例3: split_data

# 需要導入模塊: import utils [as 別名]
# 或者: from utils import split_data [as 別名]
def split_data(self, data):
        x, y = utils.split_data(data, self.y_col)
        y = self.get_is_dev_vec(y)
        return x, y 
開發者ID:Mosseridan,項目名稱:IoT-device-type-identification,代碼行數:6,代碼來源:device_session_classifier.py

示例4: load_data

# 需要導入模塊: import utils [as 別名]
# 或者: from utils import split_data [as 別名]
def load_data(cfg):
    xml_path        = cfg['xml_path']
    nb_past_steps   = int(cfg['nb_past_steps'])
    nb_future_steps = int(cfg['nb_future_steps'])
    train_fraction  = float(cfg['train_fraction'])
    valid_fraction  = float(cfg['valid_fraction'])
    test_fraction   = float(cfg['test_fraction'])

    xs, ys = load_glucose_data(xml_path, nb_past_steps, nb_future_steps)
    ys = np.expand_dims(ys, axis=1)

    x_train, x_valid, x_test = utils.split_data(xs, train_fraction,
            valid_fraction, test_fraction)
    y_train, y_valid, y_test = utils.split_data(ys, train_fraction,
            valid_fraction, test_fraction)

    # scale data
    scale = float(cfg['scale'])
    x_train *= scale
    y_train *= scale
    x_valid *= scale
    y_valid *= scale
    x_test  *= scale
    y_test  *= scale

    return x_train, y_train, x_valid, y_valid, x_test, y_test 
開發者ID:johnmartinsson,項目名稱:blood-glucose-prediction,代碼行數:28,代碼來源:ohio.py

示例5: split_data

# 需要導入模塊: import utils [as 別名]
# 或者: from utils import split_data [as 別名]
def split_data(self, data):
        data = utils.clear_missing_data(data)
        x = []
        y = []
        for dev_name, dev_sessions in data.groupby(self.y_col):
            dev_sessions = dev_sessions.drop(['device_category'], axis=1)
            dev_sessions = utils.perform_feature_scaling(dev_sessions)
            is_dev = self.is_dev(dev_name)
            seqs = self.get_sub_sequences(dev_sessions)
            x += seqs
            y += [is_dev]*len(seqs)
        return x, y 
開發者ID:Mosseridan,項目名稱:IoT-device-type-identification,代碼行數:14,代碼來源:device_sequence_classifier.py

示例6: eval_on_dataset

# 需要導入模塊: import utils [as 別名]
# 或者: from utils import split_data [as 別名]
def eval_on_dataset(self, dataset, is_dataset_csv=False):
        if is_dataset_csv:
            dataset = utils.load_data_from_csv(dataset, self.use_cols)
        # Split data to features and labels
        x, y_true = utils.split_data(dataset, self.y_col)
        # Classify data
        y_pred = self.predict(x)
        # Evaluate predictions
        return utils.eval_predictions(y_true, y_pred) 
開發者ID:Mosseridan,項目名稱:IoT-device-type-identification,代碼行數:11,代碼來源:multiple_device_classifier.py

示例7: train

# 需要導入模塊: import utils [as 別名]
# 或者: from utils import split_data [as 別名]
def train(self, train):
        x_train, y_train = utils.split_data(train, y_col=self.y_col)
        self.model.fit(x_train, y_train) 
開發者ID:Mosseridan,項目名稱:IoT-device-type-identification,代碼行數:5,代碼來源:device_session_classifier.py


注:本文中的utils.split_data方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。