本文整理汇总了Python中feature.Feature.sample_row方法的典型用法代码示例。如果您正苦于以下问题:Python Feature.sample_row方法的具体用法?Python Feature.sample_row怎么用?Python Feature.sample_row使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类feature.Feature
的用法示例。
在下文中一共展示了Feature.sample_row方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __generate_data
# 需要导入模块: from feature import Feature [as 别名]
# 或者: from feature.Feature import sample_row [as 别名]
def __generate_data(indexs, labels, features, positive_rate):
"""
generate data set according to the `indexs` and `positive_rate`
:param indexs: indexs which will select data from raw data set
:param labels: all labels of raw data set
:param features: feature matrix
:param positive_rate: positive_rate in data set
:return: feature matrix, labels, balanced indexs
"""
# balance the data set
balanced_indexs = Feature.balance_index(indexs, labels, positive_rate)
# sample labels
labels = [labels[index] for index in balanced_indexs]
# sample features
features = Feature.sample_row(features, balanced_indexs)
return features, labels, balanced_indexs