protected function AcquiaLiftReportBase::extractConversionSummaryData in Acquia Lift Connector 7
Extracts data from the raw aggregate confidence report that is prepared for use within the report rendering process.
Parameters
$items: An array of items as return from Acquia Lift.
Return value
array An associative array with information about the performance of each choice.
1 call to AcquiaLiftReportBase::extractConversionSummaryData()
- AcquiaLiftReportBase::loadConversionReportHelper in plugins/
agent_types/ AcquiaLiftAgent.inc - Handles all of the logic to load and extract a conversion report.
File
- plugins/
agent_types/ AcquiaLiftAgent.inc, line 1788 - Provides an agent type for Acquia Lift
Class
- AcquiaLiftReportBase
- Base class providing report data loading functionality common to all Acquia Lift Reports.
Code
protected function extractConversionSummaryData($items) {
if (empty($items)) {
return array();
}
$shown = array();
$counter = NAN;
$data = array();
$confidence = FALSE;
$winner = '';
$winning_value = NAN;
foreach ($items as $item) {
// Check to see if we are in a new grouping of choices.
$check = $item['choice'];
// First item in the loop so this is the control.
if (is_nan($counter) || isset($shown[$check])) {
$shown = array();
$counter = 0;
}
else {
$counter++;
}
$shown[$check] = $check;
$choice = $option_id = $item['choice'];
$choice_id = $choice;
if (strpos($choice, ':') !== FALSE) {
list($decision_name, $option_id) = explode(':', $choice);
}
if ($option_label = personalize_get_option_label_for_decision_and_choice($decision_name, $option_id)) {
$choice_id = $option_label;
}
$goals = $item['totals']['goals'];
$count = $item['totals']['count'];
// The format for percentages will already multiply by 100.
$rate = $count > 0 ? $goals / $count : 0;
$margin = ($item['bHi'] - $item['bLo']) / 2;
if ($item['signif']) {
if (is_nan($winning_value) || $item['confidence'] > $winning_value) {
$winning_value = $item['confidence'];
$winner = $counter;
$confidence = TRUE;
}
}
$data[$item['feature']][] = array(
'counter' => $counter,
'choice_id' => $choice_id,
'raw_label' => $option_id,
'goals' => $goals,
'count' => $count,
'date' => $item['date'],
'timestamp' => strtotime($item['date']),
'conversion' => $this
->formatReportPercentage($rate),
'estimated_value' => $this
->formatReportNumber($item['vMean'], TRUE, 4),
'estimated_higher' => $this
->formatReportNumber($item['bHi'], TRUE, 4),
'estimated_lower' => $this
->formatReportNumber($item['bLo'], TRUE, 4),
'margin_error' => $this
->formatReportNumber($margin, TRUE, 4),
'significant' => $item['signif'],
'control' => $counter === 0,
'confidence' => $counter === 0 ? self::DATA_NA : $this
->formatReportPercentage($item['confidence'] / 100),
'lift_default' => $counter === 0 ? self::DATA_NA : $this
->formatReportPercentage($item['lift']['default'] / 100, TRUE),
'lift_random' => $this
->formatReportPercentage($item['lift']['random'] / 100, TRUE),
);
}
$report = array(
'data' => $data,
'overview' => array(
'confidence' => $confidence,
'winner' => $winner,
),
);
return $report;
}