本文整理汇总了Python中dataset.DataSet.save_to_file方法的典型用法代码示例。如果您正苦于以下问题:Python DataSet.save_to_file方法的具体用法?Python DataSet.save_to_file怎么用?Python DataSet.save_to_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dataset.DataSet
的用法示例。
在下文中一共展示了DataSet.save_to_file方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_blend_feature_or_load_from_cache
# 需要导入模块: from dataset import DataSet [as 别名]
# 或者: from dataset.DataSet import save_to_file [as 别名]
def get_blend_feature_or_load_from_cache(
classifier,
scale,
classes_count,
x_train,
y_train,
x_test,
feature_prefix,
random_state,
cache_dir,
n_folds,
bagging_count,
):
file_suffix = "_cl" + str(classes_count) + "_" + feature_prefix + "fld" + str(n_folds) + "_bag" + str(bagging_count)
cache_file_train = os.path.join(cache_dir, "f_train_" + str(len(x_train.ids_)) + file_suffix + ".p")
cache_file_test = os.path.join(cache_dir, "f_test_" + str(len(x_test.ids_)) + file_suffix + ".p")
if os.path.isfile(cache_file_train) and os.path.isfile(cache_file_test):
print("loading features " + feature_prefix + " from files")
feature_train = DataSet.load_from_file(cache_file_train)
feature_test = DataSet.load_from_file(cache_file_test)
else:
feature_train, feature_test = get_blend_feature(
classifier, scale, classes_count, x_train, y_train, x_test, feature_prefix, random_state, n_folds
)
print("saving features " + feature_prefix + " to files")
DataSet.save_to_file(feature_train, cache_file_train)
DataSet.save_to_file(feature_test, cache_file_test)
return feature_train, feature_test
示例2: load_test_data
# 需要导入模块: from dataset import DataSet [as 别名]
# 或者: from dataset.DataSet import save_to_file [as 别名]
def load_test_data(self, sessions_df):
data_df = read_from_csv(self.task_core.test_data_file, self.task_core.n_seed
#, max_rows=50000
)
cache_file = os.path.join(self.task_core.cache_dir, 'features_test_' + str(len(data_df.index)) + '.p')
if os.path.isfile(cache_file):
print('Loading test features from file')
x = DataSet.load_from_file(cache_file)
else:
x = ds_from_df(data_df, sessions_df, True)
print('saving test features to file')
DataSet.save_to_file(x, cache_file)
return x
示例3: load_train_data
# 需要导入模块: from dataset import DataSet [as 别名]
# 或者: from dataset.DataSet import save_to_file [as 别名]
def load_train_data(self, sessions_df):
data_df = read_from_csv(self.task_core.data_file, self.task_core.n_seed
#, max_rows=50000
)
cache_file = os.path.join(self.task_core.cache_dir, 'features_train_' + str(len(data_df.index)) + '.p')
if os.path.isfile(cache_file):
print('Loading train features from file')
x = DataSet.load_from_file(cache_file)
else:
x = ds_from_df(data_df, sessions_df, False)
print('saving train features to file')
DataSet.save_to_file(x, cache_file)
labels = data_df['country_destination'].values
y = le_.transform(labels)
return x, y