本文整理匯總了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