的回复即可立即

策略分享
标签: #<Tag:0x00007f312c2204c0>

(fcymm) #1
克隆策略

GBDT多因子选股策略

本例使用GBDT算法进行模型训练和数据预测

1、新建可视化AI模板策略

2、在左侧模块导航栏“机器学习”中拖出“GBDT训练”和“GBDT预测”模块替换原有的 StockRanker 训练模块和 StockRanker 预测模块

   本例设置“GBDT训练”中的参数: 

    损失函数类型:'reg:linear',

    评价指标:'rmse',

    模型:'gbtree'

    {"Description":"实验创建于2017/8/26","Summary":"","Graph":{"EdgesInternal":[],"ModuleNodes":[{"Id":"-809","ModuleId":"BigQuantSpace.random_forest_classifier.random_forest_classifier-v1","ModuleParameters":[{"Name":"iterations","Value":10,"ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"feature_fraction","Value":1,"ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"max_depth","Value":30,"ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"min_samples_per_leaf","Value":200,"ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"key_cols","Value":"date,instrument","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"workers","Value":1,"ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"other_train_parameters","Value":"{}","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"training_ds","NodeId":"-809"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"features","NodeId":"-809"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"model","NodeId":"-809"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"predict_ds","NodeId":"-809"}],"OutputPortsInternal":[{"Name":"output_model","NodeId":"-809","OutputType":null},{"Name":"predictions","NodeId":"-809","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":2,"IsPartOfPartialRun":null,"Comment":"","CommentCollapsed":true},{"Id":"-820","ModuleId":"BigQuantSpace.dl_model_predict.dl_model_predict-v1","ModuleParameters":[{"Name":"batch_size","Value":32,"ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"n_gpus","Value":0,"ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"verbose","Value":"2:每个epoch输出一行记录","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"trained_model","NodeId":"-820"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"input_data","NodeId":"-820"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-820","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":4,"IsPartOfPartialRun":null,"Comment":"","CommentCollapsed":true},{"Id":"-827","ModuleId":"BigQuantSpace.dl_model_predict.dl_model_predict-v1","ModuleParameters":[{"Name":"batch_size","Value":32,"ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"n_gpus","Value":0,"ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"verbose","Value":"2:每个epoch输出一行记录","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"trained_model","NodeId":"-827"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"input_data","NodeId":"-827"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-827","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":5,"IsPartOfPartialRun":null,"Comment":"","CommentCollapsed":true},{"Id":"-837","ModuleId":"BigQuantSpace.random_forest_regressor.random_forest_regressor-v1","ModuleParameters":[{"Name":"iterations","Value":10,"ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"feature_fraction","Value":1,"ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"max_depth","Value":30,"ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"min_samples_per_leaf","Value":200,"ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"key_cols","Value":"date,instrument","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"workers","Value":1,"ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"other_train_parameters","Value":"{}","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"training_ds","NodeId":"-837"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"features","NodeId":"-837"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"model","NodeId":"-837"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"predict_ds","NodeId":"-837"}],"OutputPortsInternal":[{"Name":"output_model","NodeId":"-837","OutputType":null},{"Name":"predictions","NodeId":"-837","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":6,"IsPartOfPartialRun":null,"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='-809' Position='227,334,200,200'/><NodePosition Node='-820' Position='898,321,200,200'/><NodePosition Node='-827' Position='925,432,200,200'/><NodePosition Node='-837' Position='281,444,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 [5]:
    # 本代码由可视化策略环境自动生成 2019年4月18日 16:00
    # 本代码单元只能在可视化模式下编辑。您也可以拷贝代码,粘贴到新建的代码单元或者策略,然后修改。
    
    
    m2 = M.random_forest_classifier.v1(
        iterations=10,
        feature_fraction=1,
        max_depth=30,
        min_samples_per_leaf=200,
        key_cols='date,instrument',
        workers=1,
        other_train_parameters={}
    )
    
    m4 = M.dl_model_predict.v1(
        batch_size=32,
        n_gpus=0,
        verbose='2:每个epoch输出一行记录'
    )
    
    m5 = M.dl_model_predict.v1(
        batch_size=32,
        n_gpus=0,
        verbose='2:每个epoch输出一行记录'
    )
    
    m6 = M.random_forest_regressor.v1(
        iterations=10,
        feature_fraction=1,
        max_depth=30,
        min_samples_per_leaf=200,
        key_cols='date,instrument',
        workers=1,
        other_train_parameters={}
    )
    
    • 收益率130.31%
    • 年化收益率53.85%
    • 基准收益率-6.33%
    • 阿尔法0.5
    • 贝塔0.95
    • 夏普比率1.16
    • 胜率0.58
    • 盈亏比0.95
    • 收益波动率42.69%
    • 信息比率0.11
    • 最大回撤55.04%
    bigcharts-data-start/{"__id":"bigchart-c68e32a72ce3413ebecdb35daad4629f","__type":"tabs"}/bigcharts-data-end