可视化框架下,如何将两个特征因子列表合并成新的特征因子列表?

新手专区
标签: #<Tag:0x00007f73fcc96068>

(chaoskey) #1

# 用作机器学习的特征
m1 = M.input_features.v1( 
    features="""
rank_return_20
"""
)

# 用作过滤判判断的因子,不用作机器学习的特征
m2 = M.input_features.v1( 
    features="""
return_5
"""
)

# 目标:可视化框架下,如何将两个特征因子列表合并成新的特征因子列表?

(iQuant) #2

这个模块还没有添加上去,我们在逐步添加更多的模块(用户也可以上传自己的模块)。

但通过自定义模块可以非常容易的实现这个功能(我们将把这个做成一个标准模块):

克隆策略

    {"Description":"实验创建于2017/9/27","Summary":"","Graph":{"EdgesInternal":[{"DestinationInputPortId":"-184:input_1","SourceOutputPortId":"-173:data"},{"DestinationInputPortId":"-184:input_2","SourceOutputPortId":"-176:data"}],"ModuleNodes":[{"Id":"-173","ModuleId":"BigQuantSpace.input_features.input_features-v1","ModuleParameters":[{"Name":"features","Value":"# #号开始的表示注释\n# 多个特征,每行一个,可以包含基础特征和衍生特征\nreturn_5\nclose_0 / close_1\n","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[],"OutputPortsInternal":[{"Name":"data","NodeId":"-173","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":1,"Comment":"","CommentCollapsed":true},{"Id":"-176","ModuleId":"BigQuantSpace.input_features.input_features-v1","ModuleParameters":[{"Name":"features","Value":"# #号开始的表示注释\n# 多个特征,每行一个,可以包含基础特征和衍生特征\nreturn_10\n","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[],"OutputPortsInternal":[{"Name":"data","NodeId":"-176","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":2,"Comment":"","CommentCollapsed":true},{"Id":"-184","ModuleId":"BigQuantSpace.cached.cached-v3","ModuleParameters":[{"Name":"run","Value":"# Python 代码入口函数,input_1/2/3 对应三个输入端,data_1/2/3 对应三个输出端\ndef bigquant_run(input_1, input_2, input_3):\n s = input_1.read_pickle().strip() + '\\n' \n s += input_2.read_pickle().strip() + '\\n'\n data_1 = DataSource.write_pickle(s)\n return Outputs(data_1=data_1, data_2=None, data_3=None)\n","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"input_1","NodeId":"-184"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"input_2","NodeId":"-184"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"input_3","NodeId":"-184"}],"OutputPortsInternal":[{"Name":"data_1","NodeId":"-184","OutputType":null},{"Name":"data_2","NodeId":"-184","OutputType":null},{"Name":"data_3","NodeId":"-184","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":3,"Comment":"","CommentCollapsed":true}],"SerializedClientData":"<?xml version='1.0' encoding='utf-16'?><DataV1 xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><Meta /><NodePositions><NodePosition Node='-173' Position='259,133,200,200'/><NodePosition Node='-176' Position='578,136,200,200'/><NodePosition Node='-184' Position='443.199951171875,236.70001220703125,200,200'/></NodePositions><NodeGroups /></DataV1>"},"IsDraft":true,"ParentExperimentId":null,"WebService":{"IsWebServiceExperiment":false,"Inputs":[],"Outputs":[],"Parameters":[{"Name":"交易日期","Value":"","ParameterDefinition":{"Name":"交易日期","FriendlyName":"交易日期","DefaultValue":"","ParameterType":"String","HasDefaultValue":true,"IsOptional":true,"ParameterRules":[],"HasRules":false,"MarkupType":0,"CredentialDescriptor":null}}],"WebServiceGroupId":null,"SerializedClientData":"<?xml version='1.0' encoding='utf-16'?><DataV1 xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><Meta /><NodePositions></NodePositions><NodeGroups /></DataV1>"},"DisableNodesUpdate":false,"Category":"user","Tags":[],"IsPartialRun":false}
    In [3]:
    # 本代码由可视化策略环境自动生成 2017年9月27日 13:57
    # 本代码单元只能在可视化模式下编辑。您也可以拷贝代码,粘贴到新建的代码单元或者策略,然后修改。
    
    
    m1 = M.input_features.v1(
        features="""# #号开始的表示注释
    # 多个特征,每行一个,可以包含基础特征和衍生特征
    return_5
    close_0 / close_1
    """
    )
    
    m2 = M.input_features.v1(
        features="""# #号开始的表示注释
    # 多个特征,每行一个,可以包含基础特征和衍生特征
    return_10
    """
    )
    
    # Python 代码入口函数,input_1/2/3 对应三个输入端,data_1/2/3 对应三个输出端
    def m3_run_bigquant_run(input_1, input_2, input_3):
        s = input_1.read_pickle().strip() + '\n' 
        s += input_2.read_pickle().strip() + '\n'
        data_1 = DataSource.write_pickle(s)
        return Outputs(data_1=data_1, data_2=None, data_3=None)
    
    m3 = M.cached.v3(
        input_1=m1.data,
        input_2=m2.data,
        run=m3_run_bigquant_run
    )
    
    [2017-09-27 13:56:47.430758] INFO: bigquant: input_features.v1 开始运行..
    [2017-09-27 13:56:47.435861] INFO: bigquant: input_features.v1 运行完成[0.005135s].
    [2017-09-27 13:56:47.440701] INFO: bigquant: input_features.v1 开始运行..
    [2017-09-27 13:56:47.444702] INFO: bigquant: input_features.v1 运行完成[0.004013s].
    [2017-09-27 13:56:47.453420] INFO: bigquant: cached.v3 开始运行..
    [2017-09-27 13:56:47.459440] INFO: bigquant: cached.v3 运行完成[0.006017s].
    
    In [5]:
    print(m3.data_1.read_pickle())
    
    # #号开始的表示注释
    # 多个特征,每行一个,可以包含基础特征和衍生特征
    return_5
    close_0 / close_1
    # #号开始的表示注释
    # 多个特征,每行一个,可以包含基础特征和衍生特征
    return_10
    
    

    (chaoskey) #3

    谢谢您再次提醒: 不方便实现的功能,一定要想到自定义模块。