# Create predictive scoring model (legacy)

Create a new predictive scoring model.  _This endpoint is for Audience Studio legacy. For the latest Audience Studio, contact your Customer Success Representative._

Endpoint: POST /audiences/{audienceId}/predictive_segments
Version: 1.0.0
Security: TdApikeyAuth

## Path parameters:

  - `audienceId` (integer, required)
    Master Segment id of the preditive segment

## Request fields (application/json):

  - `name` (string)

  - `description` (string,null)

  - `baseSegmentId` (integer,null)

  - `segmentId` (integer)

  - `scoredSegmentId` (integer,null)

  - `gradeThresholds` (array)
    Given the items [a, b, c], they must meet the condition a >= b >= c
    Example: [75,50,25]

  - `categoricalAsColumnNames` (array)

  - `categoricalArrayAsColumnNames` (array)

  - `quantitativeAsColumnNames` (array)

  - `preprocess` (array)
    Definition of preprocess. All of $item.column must be specified in one of categoricalAsColumnNames, categoricalArrayAsColumnNames, or quantitativeAsColumnNames.

  - `preprocess.column` (string, required)

  - `preprocess.source` (object, required)

  - `preprocess.source.column` (string)

  - `preprocess.source.table` (string)

  - `preprocess.source.functions` (array) — one of:
    - variant 1:
      - `function` (string, required)
        Enum: "+", "-", "*", "/"
      - `arg` (number)
    - variant 2:
      - `function` (string, required)
        Enum: "replace"
      - `search` (string)
      - `replacement` (string,null)
    - variant 3:
      - `function` (string, required)
        Enum: "substr"
      - `start` (number)
      - `length` (number)
    - variant 4:
      - `function` (string, required)
        Enum: "regexp_extract"
      - `pattern` (string)
      - `group` (number)
    - variant 5:
      - `function` (string, required)
        Enum: "day_of_week", "from_iso8601_timestamp", "ln", "elapsed_days", "td_ip_to_least_specific_subdivision_name", "td_ip_to_country_name", "td_ip_to_city_name", "td_ip_to_connection_type", "td_ip_to_domain"
    - variant 6:
      - `function` (string, required)
        Enum: "cast_as_quantitative"
      - `default` (number, required)
    - variant 7:
      - `function` (string, required)
        Enum: "cast_as_categorical"
      - `default` (string, required)
    - variant 8:
      - `function` (string, required)
        Enum: "cast_as_categorical_array"
    - variant 9:
      - `function` (string, required)
        Enum: "if"
      - `op` (string)
        Enum: ">", "<", "<=", ">=", "=", "!=", "is", "is\\", "not"
      - `right_value` (number,null)
      - `then` (number)
      - `else` (number)

## Response 200 fields (application/json):

  - `audienceId` (string)

  - `id` (string)

  - `baseSegmentId` (string,null)

  - `segmentId` (string)

  - `scoredSegmentId` (string,null)

  - `name` (string)

  - `description` (string,null)

  - `categoricalAsColumnNames` (array)

  - `categoricalArrayAsColumnNames` (array)

  - `quantitativeAsColumnNames` (array)

  - `accuracy` (number,null)
    Accuracy for trained model evaluated on initial training.

  - `areaUnderRocCurve` (number,null)
    Evaluation score for the model. See also https://en.wikipedia.org/wiki/Receiver_operating_characteristic#Area_under_the_curve

  - `gradeThresholds` (array)
    Given the items [a, b, c], they must meet the condition a >= b >= c
    Example: [75,50,25]

  - `createdAt` (string)

  - `updatedAt` (string)

## Response 400 fields (application/json):

  - `code` (string, required)

  - `message` (string, required)

## Response 5XX fields (application/json):

  - `status` (integer, required)
    Error status

  - `error` (string, required)
    Error message

  - `details` (string)
    Detailed error message


