本文整理汇总了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
示例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
示例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
示例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
示例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
示例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)
示例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)