小编Gab*_*elG的帖子

为机器学习打开 ROOT NTuple 的最快、最节省内存的方法是什么?

我正在使用 scikit learn 建立一个机器学习项目。输入数据是平面 ROOT NTuples。

过去我一直使用 root_numpy 将 NTuples 转换为保存在 h5 文件中的 pandas.DataFrame 。

我想知道我是否可以使用 uproot 来
a) 完全跳过 h5 转换?
b) 不使用与从 h5 加载到 DataFrame 中一样多的内存?

我天真的第一次尝试看起来像这样:

'''
Runs preselection, keeps only desired variables in DataFrame
'''
def dropAndKeep(df, dropVariables=None, keepVariables=None, presel=None, inplace=True):

    if ((presel is not None) and (not callable(presel))):
        print("Please either provide a function to 'presel' or leave blank")
        raise ValueError

    if callable(presel):
        if not(inplace):
            df = df.drop(df[~presel(df)].index, inplace=False)
        else:
            df.drop(df[~presel(df)].index, inplace=True)

    if keepVariables is not …
Run Code Online (Sandbox Code Playgroud)

python machine-learning scikit-learn uproot

3
推荐指数
1
解决办法
1570
查看次数

标签 统计

machine-learning ×1

python ×1

scikit-learn ×1

uproot ×1