Chỉ định thuật toán

Chỉ định thuật toán cho một tài nguyên khi thuật toán đó đã sẵn sàng.

Kiểm tra xem thuật toán đã sẵn sàng hay chưa

Một mô hình thuật toán phải được huấn luyện dựa trên lượng dữ liệu tối thiểu trước khi sẵn sàng.

Các thuật toán sẽ huấn luyện một mô hình cho từng nhà quảng cáo có thể sử dụng mô hình đó. Các mô hình huấn luyện dựa trên dữ liệu về lượt hiển thị hiện có. Có thể mất từ 1 đến 3 ngày để huấn luyện một mô hình sau khi nhà quảng cáo đáp ứng các yêu cầu về dữ liệu.

Truy xuất trạng thái sẵn sàng của từng mô hình từ thuật toán. ReadinessState sẽ xác định các bước tiếp theo:

ReadinessState
READINESS_STATE_NO_VALID_SCRIPT Không có tập lệnh hợp lệ. Tải một tập lệnh hoặc tệp quy tắc mới lên.
READINESS_STATE_EVALUATION_FAILURE Không có tập lệnh nào có thể được đánh giá trong thời gian được phân bổ. Tải một tập lệnh hoặc tệp quy tắc mới lên.
READINESS_STATE_INSUFFICIENT_DATA Nhà quảng cáo không có đủ dữ liệu để huấn luyện mô hình. Tiếp tục chạy chiến dịch trong tài khoản nhà quảng cáo để đáp ứng các yêu cầu tối thiểu về dữ liệu.
READINESS_STATE_TRAINING Mô hình đang huấn luyện trên dữ liệu hiện có và chưa sẵn sàng để phân phát. Hãy đợi 12 đến 24 giờ rồi kiểm tra xem mô hình đã sẵn sàng phân phát hay chưa.
READINESS_STATE_ACTIVE Mô hình này đã được huấn luyện đầy đủ và sẵn sàng được chỉ định cho các chiến dịch của nhà quảng cáo.

Chỉ định thuật toán cho mục hàng

Thuật toán được dùng để đo lường và điều chỉnh hiệu suất đặt giá thầu. Bạn có thể sử dụng chiến lược này với những chiến lược giá thầu tối ưu hoá để chi tiêu toàn bộ ngân sách hoặc đạt được mục tiêu. Trong những trường hợp này, loại mục tiêu hiệu suất của chiến lược sẽ là BIDDING_STRATEGY_PERFORMANCE_GOAL_TYPE_CUSTOM_ALGO.

Sau đây là cách cập nhật một mục hàng để sử dụng một thuật toán có chiến lược giá thầu giúp tối ưu hoá việc chi tiêu toàn bộ ngân sách:

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']
);