本文整理汇总了Python中ModelingMachine.engine.partition.Partition.partitions方法的典型用法代码示例。如果您正苦于以下问题:Python Partition.partitions方法的具体用法?Python Partition.partitions怎么用?Python Partition.partitions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ModelingMachine.engine.partition.Partition
的用法示例。
在下文中一共展示了Partition.partitions方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_cf_syn_data
# 需要导入模块: from ModelingMachine.engine.partition import Partition [as 别名]
# 或者: from ModelingMachine.engine.partition.Partition import partitions [as 别名]
def create_cf_syn_data(self, n_samples=1000, n_users=500, n_items=10, reps=1, folds=0,
categoricals=False):
rs = np.random.RandomState(13)
user_ids = rs.randint(0, n_users, size=n_samples)
if categoricals:
user_ids = map(lambda ui: 'UID-%d' % ui, user_ids)
item_ids = rs.randint(0, n_items, size=n_samples)
if categoricals:
item_ids = map(lambda ii: 'IID-%d' % ii, item_ids)
X = pd.DataFrame(data=OrderedDict([('user_id', user_ids),
('item_id', item_ids)]))
# set special columns to adhere blueprint_interpreter.BuildData.dataframe
X.special_columns = {'I': 'item_id', 'U': 'user_id'}
Y = Response.from_array(rs.randint(1, 5, size=n_samples))
Z = Partition(size=X.shape[0],folds=5,reps=reps,total_size=X.shape[0])
Z.set(max_reps=reps,max_folds=folds)
if reps == -1 and folds == -1:
Z.partitions = [(-1, -1)]
X = Container(dataframe=X)
return X, Y, Z