Returns the sample data of a prediction.

@param \stdClass $predictionobj
@return array
191097
public function prediction_sample_data($predictionobj) {

        list($unused, $samplesdata) = $this->get_analyser()->get_samples(array($predictionobj->sampleid));

        if (empty($samplesdata[$predictionobj->sampleid])) {
            throw new \moodle_exception('errorsamplenotavailable', 'analytics');
        }

        return $samplesdata[$predictionobj->sampleid];
    }
1148975
protected function generateDbData()
    {
        $dbData = [];
        foreach ($this->data as $name => $value) {
            if ($this->getDataSource($name) !== 'db') {
                $dbData[$name] = $this->getSetValue($name, $value);
            } else {
                $dbData[$name] = $value;
            }
        }

        return $dbData;
    }
764420
public static function getMeta($refobj) {
        $fname = $refobj->getFileName();
        $lines = file_get_contents($fname);
        $file = new \SplFileObject($fname);
        $file->seek($refobj->getStartLine() - 2);
        $spos = $file->ftell();
        $file->seek($refobj->getEndLine() - 1);
        $epos = $file->ftell();
        unset($file);
        return array(
            'name' => $refobj->getName(),
            'code' => substr($lines, $spos, $epos - $spos)
        );
    }
269595
private function getRecordEditingFields(DataObject $record)
    {
        $tempForm = Form::create(
            $this,
            'TempEditForm',
            $record->getCMSFields(),
            FieldList::create()
        );

        $tempForm->loadDataFrom($record);
        $fields = $tempForm->Fields();

        $fields = $this->filterRecordEditingFields($fields, $record->ID);

        return $fields;
    }
953288
protected function objectToArray($obj) : array
    {
        if ($obj instanceof \stdClass) {
            $obj = json_decode(json_encode($obj), true);
        }

        return (array)$obj;
    }
603481
public static function get_predictions_processor($predictionclass = false, $checkisready = true) {

        // We want 0 or 1 so we can use it as an array key for caching.
        $checkisready = intval($checkisready);

        if (!$predictionclass) {
            $predictionclass = get_config('analytics', 'predictionsprocessor');
        }

        if (empty($predictionclass)) {
            // Use the default one if nothing set.
            $predictionclass = self::default_mlbackend();
        }

        if (!class_exists($predictionclass)) {
            throw new \coding_exception('Invalid predictions processor ' . $predictionclass . '.');
        }

        $interfaces = class_implements($predictionclass);
        if (empty($interfaces['core_analytics\predictor'])) {
            throw new \coding_exception($predictionclass . ' should implement \core_analytics\predictor.');
        }

        // Return it from the cached list.
        if (!isset(self::$predictionprocessors[$checkisready][$predictionclass])) {

            $instance = new $predictionclass();
            if ($checkisready) {
                $isready = $instance->is_ready();
                if ($isready !== true) {
                    throw new \moodle_exception('errorprocessornotready', 'analytics', '', $isready);
                }
            }
            self::$predictionprocessors[$checkisready][$predictionclass] = $instance;
        }

        return self::$predictionprocessors[$checkisready][$predictionclass];
    }
1364201
protected function getPageSnippets($SHDObject)
    {
        $snippets = array();
        foreach ($SHDObject->find('.aAbs') as $object) {
            $snippetText = $this->cleanText($object->innertext);
            $snippets[]  = $this->fixRepeatedSpace($snippetText);
        }
        // fetch only organic results
        return $this->normalizeResult($snippets);
    }
625641
public function pegaAtributosDoObjeto($obj)
    {
        $properties      = [];
        $reflectionClass = new ReflectionClass($obj);
        $propriedades    = $reflectionClass->getProperties(
            ReflectionProperty::IS_PUBLIC |
            ReflectionProperty::IS_PROTECTED | 
            ReflectionProperty::IS_PRIVATE
        );
     
        $iterator = 0;
        $limit    = count($propriedades);
        for ($iterator = 0; $iterator < $limit; $iterator++) {
            $properties[$iterator] = $propriedades[$iterator]->name;
        }

        return $properties;
    }
1245988
private function dataFromObj(Refund $refund)
	{
		$data = array();
		$data['refund_id'] = $refund->refund_id;
		$data['amount'] = $refund->amount;
		$data['status'] = $refund->status;

		foreach ($data as $key => $value) {
			if ($value === null) {
				unset($data[$key]);
			}
		}

		return $data;
	}
597379
public function fetchAllObj(string $class = null): array
    {
        if ($class == null && $this->modelClass !== null) {
            return parent::fetchAllObj($this->modelClass);
        } else {
            return parent::fetchAllObj($class);
        }
    }
298261
public function predict(Dataset $dataset) : array
    {
        if (!$this->trained) {
            throw new RuntimeException('The learner has not'
                . ' been trained.');
        }
        
        $n = $dataset->numRows();

        $predictions = [];

        for ($i = 0; $i < $n; $i++) {
            $predictions[] = $this->strategy->guess();
        }

        return $predictions;
    }
513234
public function getData() : \stdClass
    {
        $output = new \stdClass();

        foreach ($this->data as $key => $property) {
            if ($this->options['lowercase']) {
                $key = strtolower($key);
            }

            $output->{$key} = $property;
        }

        return $output;
    }
1007454
protected function GetExportRowFromDataObject(&$oDataObjct)
    {
        $aRow = parent::GetExportRowFromDataObject($oDataObjct);
        $oLocale = &TCMSLocal::GetActive();
        $aRow['stats_review_average'] = $oLocale->FormatNumber($aRow['stats_review_average'], 2);

        return $aRow;
    }
1103555
private function getBBVariable()
    {
        return [
            'bb' => [
                'debug'      => $this->getApplication()->isDebugMode(),
                'token'      => $this->getApplication()->getBBUserToken(),
                'request'    => $this->getApplication()->getRequest(),
                'routing'    => $this->getApplication()->getRouting(),
                'translator' => $this->getApplication()->getContainer()->get('translator'),
            ],
        ];
    }
1255561
public function getDataObj(bool $trimStrings = null): \stdClass
    {
        $obj = new \stdClass();
        foreach ($this->getData($trimStrings ?? true) as $key => $value) {
            $obj->$key = $value;
        }

        return $obj;
    }
714117
public function getTemplateOutput($templateName, $oObject)
    {
        $smarty = $this->getSmarty();
        $debugMode = \OxidEsales\Eshop\Core\Registry::getConfig()->getConfigParam('iDebug');

        // assign
        $viewData = $oObject->getViewData();
        if (is_array($viewData)) {
            foreach (array_keys($viewData) as $viewName) {
                // show debug information
                if ($debugMode == 4) {
                    echo("TemplateData[$viewName] : \n");
                    var_export($viewData[$viewName]);
                }
                $smarty->assign($viewName, $viewData[$viewName]);
            }
        }

        return $smarty->fetch($templateName);
    }
327351
public static function formatted_dates($startObj, $endObj)
    {

        //Checking if end date is set
        $endDateIsset = true;
        if (isset($endObj->value)) {
            $endDateIsset = false;
        }

        $startTime = strtotime($startObj->value);
        $endTime = strtotime($endObj->value);

        $startMonth = date('M', $startTime);
        $startDayOfMonth = $startObj->DayOfMonth(true);
        $str = $startMonth . ' ' . $startDayOfMonth;

        if (date('Y-m-d', $startTime) == date('Y-m-d', $endTime)) {
            //one date - str. has already been written
        } else {
            //two dates

            if ($endDateIsset) {
                $endMonth = date('M', $endTime);
                $endDayOfMonth = $endObj->DayOfMonth(true);

                if ($startMonth == $endMonth) {
                    $str .= ' - ' . $endDayOfMonth;
                } else {
                    $str .= ' - ' . $endMonth . ' ' . $endDayOfMonth;
                }
            }
        }
        return $str;
    }