次の方法で共有


Data Science ツールキット - ロジスティック回帰モデル API リソース

このドキュメントの目的は、ロジスティック回帰モデル、ルックアップ テーブル、ハッシュ テーブル予測変数の作成を可能にする、Data Science Toolkit サービスの一時的な API リソースとして機能することです。

記述子リスト

スカラー記述子

型:

"scalar_descriptor"

機能:

  • appnexus``_audited
  • cookie_age
  • estimated_average_price
  • estimated_clearing_price
  • predicted_iab_view_rate
  • predicted_video_completion_rate
  • self_audited
  • size
  • creative_size
  • spend_protection
  • uniform
  • user_age

注:

記述子は size 、モデル内の文字列 ("300x250"など) として表されますが、入札者のスカラーに変換されます。 どのサイズもシステムで技術的に有効であるため、この機能はカテゴリ的特徴ではなくスカラーとして扱われます。

例:

{
    "type": "scalar_descriptor",
    "feature_keyword": "cookie_age",
    "default_value": 0,               //Value returned by the descriptor if no match is found
    "initial_range_log": 4,           //Used for log bucketing, initial range
    "bucket_count_log_per_range": 2   //used for log bucketing, # of buckets per range
}

セグメント記述子

型:

"segment_descriptor"

機能:

  • segment_value
  • segment_age
  • segment_presence

例:

{
    "type": "segment_descriptor",
    "feature_keyword": "segment_age",
    "segment_id": 2,                  //ID of referenced segment
    "default_value": 0,               //Value returned by the descriptor if no match is found
    "initial_range_log": 4,           //Used for log bucketing, initial range
    "bucket_count_log_per_range": 2   //used for log bucketing, # of buckets per range
}

Frequency/Recency 記述子

型:

"frequency_recency_descriptor"

機能:

  • frequency_life
  • frequency_daily
  • recency

この記述子で使用できるオブジェクトの種類:

  • advertiser
  • line_item
  • campaign

例:

{
    "type": "frequency_recency_descriptor",
    "feature_keyword": 'frequency_life',
    "object_type": 'advertiser',
    "object_id": 1,                   //ID of the referenced advertiser, 
    "default_value": 0,               //Value returned by the descriptor if no match is found
    "initial_range_log": 4,           //Used for log bucketing, initial range
    "bucket_count_log_per_range": 2   //used for log bucketing, # of buckets per range
}

カテゴリ記述子

型:

"categorical_descriptor"

機能:

  • country
  • region
  • city
  • dma
  • postal_code
  • user_day
  • user_hour
  • os_family
  • os_extended
  • browser
  • language
  • user_gender
  • domain
  • ip_address
  • position
  • placement
  • placement_group
  • publisher
  • seller_member_id
  • supply_type
  • device_type
  • device_model
  • carrier
  • mobile_app
  • mobile_app_instance
  • mobile_app_bundle
  • appnexus``_intended_audience
  • seller_intended_audience
  • spend_protection
  • user_group_id
  • advertiser_id
  • brand_category
  • creative
  • inventory_url_id
  • media_type

例:

{
    "type": "categorical_descriptor",
    "feature_keyword": "city"
}

ハッシュ テーブル記述子

型:

"hashed"

例:

{
    "type": "hashed",
    "keys": [ array of one to 5 descriptors in this list:
        scalar_descriptor,
        custom_model_descriptor,
        freq_rec_descriptor,
        segment_descriptor,
        categorical_descriptor
    ],
    "hash_seeds": [42, 42, 42, 42, 42, 42],  //Seeds used when passed to Murmurhash3_x64_128 function, only first one is used for now, array is for planned future hash functions that need more than one seed
    "hash_id": <existing hash table ID>,
    "default_value": 0,                      //Value returned by the descriptor if no match is found in your hash table
    "hash_table_size_log": 20                //log of maximum value for a key of your table. Values larger than 2^hash_table_size_log will be rejected. Max for hash_table_size_log is 64 (no bucketing)
}

ハッシュ テーブル

このエンドポイントは、事前ハッシュテーブルを送信することです。 bucket_index0bucket_index1では、長い 64 ビットごとに、キーとして長い値を生成するハッシュ アルゴリズムをサポートします。 現時点では、1 つのハッシュ アルゴリズムのみをサポートしています。 MurmurHash3_x64_128これは、2 つの 64 ビット整数を作成しますが、ハッシュの下位 64 ビットのみを使用します。

bucket_index0 値は常に より (2 ^ hash_table_size_log) 小さくする必要があります。または拒否されます。

現時点では、 の bucket_index1 値は無視されます。これは将来の拡張に使用されるためです。 に値が送信される bucket_index1場合は、 である 0必要があります。 パラメーターは省略可能です。

ハッシュ テーブル キー

ハッシュ テーブル キーごとに、uint32 値が必要です。 これらの値は、たとえば、ドメイン文字列値ではなく、システム domain_idから参照している各オブジェクトの ID である必要があります。 これらの uint32 キーはバイト配列 (リトル エンディアン) に変換され、ハッシュされます。

Python の例

hash_bucket = (mmh3.hash64(bytes, seed)[0]) % table_size

Logit 関数

モデルの作成と更新は似ていますが、両方に同じ要求形式が使用されます。

メソッド エンドポイント 用途
GET /custom-model-logit 指定されたパラメーターに関連付けられている Logit 関数を取得します。
PUT /custom-model-logit JSON ペイロード内のデータを使用して、既存の Logit 関数を更新します。
POST /custom-model-logit JSON ペイロード内のデータから新しい Logit 関数を作成します。
DELETE /custom-model-logit 指定されたパラメーターに一致する既存の Logit 関数を削除します。

パラメーター

名前 データ型 パラメーターの型 必須
id int クエリ GET, PUT, DELETE ?id=1
member_id int クエリ PUT, POST ?member_id=1

POST

{"custom-model-logit": {
  "member_id": 1,
  "beta0": 1.2,
  "max": 5,
  "min": 0,  //optional, will be set to 0 if not passed
  "name": "Sample LRE model",
  "offset": 0.3, //optional, will be set to 0 if not passed
  "scale": 1.5, //optional, will be set to 1 if not passed
  "predictors": [
    {
      "coefficient": 0.2,
      "feature_descriptor": {
        "bucket_count_log_per_range": 31,
        "default_value": 0,
        "feature_keyword": "size",
        "initial_range_log": 31,
        "type": "scalar_descriptor"
      },
      "type": "scalar"
    },
    {
      "coefficient": 0.3,
      "feature_descriptor": {
        "bucket_count_log_per_range": 31,
        "custom_model_id": 2,
        "default_value": 0,
        "feature_keyword": "custom_model",
        "initial_range_log": 31,
        "type": "custom_model_descriptor"
      },
      "type": "scalar"
    },
    {
      "coefficient": 0.4,
      "feature_descriptor": {
        "bucket_count_log_per_range": 31,
        "default_value": 0,
        "feature_keyword": "frequency_life",
        "initial_range_log": 31,
        "object_id": 1,
        "object_type": "advertiser",
        "type": "frequency_recency_descriptor"
      },
      "type": "scalar"
    },
    {
      "coefficient": 0.5,
      "feature_descriptor": {
        "bucket_count_log_per_range": 31,
        "default_value": 0,
        "feature_keyword": "segment_age",
        "initial_range_log": 31,
        "segment_id": 2,
        "type": "segment_descriptor"
      },
      "type": "scalar"
    },
    {
        "type": "hashed",
        "keys": [
            {
                "type": "categorical_descriptor",
                "feature_keyword": "advertiser_id"
            },
            {
                "type": "scalar_descriptor",
                "feature_keyword": "user_age",
                "default_value": 0
            }
        ],
        "hash_seeds": [42, 42, 42, 42, 42, 42],
        "default_value": 0,
        "hash_table_size_log": 20,
        "coefficients": [
            {"bucket_index0": 0, "bucket_index1": 0, "weight": 1.3},
            {"bucket_index0": 1, "bucket_index1": 0, "weight": 0.7},
            {"bucket_index0": 2, "bucket_index1": 0, "weight": 1.5},
            {"bucket_index0": 3, "bucket_index1": 0, "weight": 0.9}
        ]
    },
    {
        "type": "lookup",
        "default_value": 0.1,
        "features": [
            {
                "type": "categorical_descriptor",
                "feature_keyword": "advertiser_id"
            },
            {
                "type": "scalar_descriptor",
                "feature_keyword": "user_age",
                "default_value": 0
            }
        ],
        "coefficients": [
            {'weight': 1.1, 'key': [1, 1]},
            {'weight': 1.3, 'key': [2, 2]},
            {'weight': 1.2, 'key': [3, 3]},
        ]
    }
  ]
}}

ロジスティック回帰カスタム モデル サービス