在算法准备就绪后,将其分配给资源。
检查算法是否已准备就绪
算法模型必须先基于最低数据量进行训练,然后才能投入使用。
算法会为每个可以使用以数据为依据的归因模型的广告客户训练一个模型。模型根据现有的展示数据进行训练。广告客户满足数据要求后,模型可能需要 1-3 天的时间进行训练。
从算法中检索每个模型的就绪状态。ReadinessState 决定了后续步骤:
ReadinessState | |
|---|---|
READINESS_STATE_NO_VALID_SCRIPT |
没有有效的脚本。上传新的脚本或规则文件。 |
READINESS_STATE_EVALUATION_FAILURE |
没有可在分配的时间内评估的脚本。上传新的脚本或规则文件。 |
READINESS_STATE_INSUFFICIENT_DATA |
相应广告客户提供的数据不足,无法训练模型。继续在相应广告客户账号下投放广告系列,以满足最低数据要求。 |
READINESS_STATE_TRAINING |
模型正在基于现有数据进行训练,尚未准备好进行部署。等待 12-24 小时,然后再检查模型是否已准备好进行部署。 |
READINESS_STATE_ACTIVE |
模型已完成训练,可以分配给相应广告客户名下的广告系列。 |
将算法分配给订单项
系统会使用算法来衡量和调整出价效果。它可以与以用尽全部预算或实现目标为优化目标的出价策略搭配使用。在这种情况下,策略效果目标类型将为 BIDDING_STRATEGY_PERFORMANCE_GOAL_TYPE_CUSTOM_ALGO。
下面介绍了如何更新订单项,以使用出价策略中的算法来优化预算支出,从而用尽整个预算:
Java
// Provide the ID of the advertiser that owns the parent algorithm. long advertiserId = advertiser-id; // Provide the ID of the parent algorithm. long algorithmId = algorithm-id; // Provide the ID of the line item to assign the algorithm to. long lineItemId = line-item-id; // Create the line item structure. LineItem lineItem = new LineItem() .setBidStrategy( new BiddingStrategy() .setMaximizeSpendAutoBid( new MaximizeSpendBidStrategy() .setPerformanceGoalType( "BIDDING_STRATEGY_PERFORMANCE_GOAL_TYPE_CUSTOM_ALGO") .setCustomBiddingAlgorithmId(algorithmId))); // Configure the patch request and set update mask to only update the bid // strategy. LineItems.Patch request = service .advertisers() .lineItems() .patch(advertiserId, lineItemId, lineItem) .setUpdateMask("bidStrategy"); // Update the line item. LineItem response = request.execute(); // Display the new algorithm ID used by the line item. System.out.printf( "Line item %s now uses algorithm ID %s in its bidding strategy.", response.getName(), response.getBidStrategy().getMaximizeSpendAutoBid().getCustomBiddingAlgorithmId());
Python
# Provide the parent advertiser ID of the line item and creative. advertiser_id = advertiser-id # Provide the ID of the creative to assign. algorithm_id = algorithm-id # Provide the ID of the line item to assign the creative to. line_item_id = line-item-id # Build bidding strategy object. bidding_strategy_obj = { "maximizeSpendAutoBid": { "performanceGoalType": ( "BIDDING_STRATEGY_PERFORMANCE_GOAL_TYPE_CUSTOM_ALGO" ), "customBiddingAlgorithmId": algorithm_id, } } # Build line item object. line_item_obj = {"bidStrategy": bidding_strategy_obj} # Build and execute request. line_item_resp = ( service.advertisers() .lineItems() .patch( advertiserId=advertiser_id, lineItemId=line_item_id, updateMask="bidStrategy", body=line_item_obj, ) .execute() ) # Print the algorithm ID now assigned to the line item. print( f'Line Item {line_item_resp["name"]} now uses algorithm ID' f' {line_item_resp["bidStrategy"]["maximizeSpendAutoBid"]["customBiddingAlgorithmId"]}' " in its bidding strategy." )
PHP
// Provide the ID of the advertiser that owns the parent algorithm. $advertiserId = advertiser-id; // Provide the ID of the parent algorithm. $algorithmId = algorithm-id; // Provide the ID of the line item to assign the algorithm to. $lineItemId = line-item-id; // Create the bidding strategy structure. $maxSpendBidStrategy = new Google_ServiceDisplayVideo_MaximizeSpendBidStrategy(); $maxSpendBidStrategy->setPerformanceGoalType('BIDDING_STRATEGY_PERFORMANCE_GOAL_TYPE_CUSTOM_ALGO'); $maxSpendBidStrategy->setCustomBiddingAlgorithmId($algorithmId); $biddingStrategy = new Google_ServiceDisplayVideo_BiddingStrategy(); $biddingStrategy->setMaximizeSpendAutoBid($maxSpendBidStrategy); // Create the line item structure. $lineItem = new Google_Service_DisplayVideo_LineItem(); $lineItem->setBidStrategy($biddingStrategy); $optParams = array('updateMask' => 'bidStrategy'); // Call the API, updating the bid strategy for the identified line // item. try { $result = $this->service->advertisers_lineItems->patch( $advertiserId, $lineItemId, $lineItem, $optParams ); } catch (\Exception $e) { $this->renderError($e); return; } printf( '<p>Line Item %s now uses algorithm ID %s in its bid strategy.</p>', $result['name'], $result['bidStrategy']['maximizeSpendAutoBid']['customBiddingAlgorithmId'] );