idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
23,600 | protected function registerValidator ( ) { $ this -> app -> resolving ( 'validator' , function ( $ validator ) { $ validator -> extend ( 'extensions' , function ( $ attribute , $ value , $ parameters ) { $ extension = strtolower ( $ value -> getClientOriginalExtension ( ) ) ; return in_array ( $ extension , $ parameter... | Extends the validator with custom rules |
23,601 | public function getPublicPath ( ) { $ uploadsPath = Config :: get ( 'cms.storage.uploads.path' , '/storage/app/uploads' ) ; if ( $ this -> isPublic ( ) ) { $ uploadsPath .= '/public' ; } else { $ uploadsPath .= '/protected' ; } return Url :: asset ( $ uploadsPath ) . '/' ; } | Define the public address for the storage path . |
23,602 | protected function copyLocalToStorage ( $ localPath , $ storagePath ) { $ disk = Storage :: disk ( Config :: get ( 'cms.storage.uploads.disk' ) ) ; return $ disk -> put ( $ storagePath , FileHelper :: get ( $ localPath ) , $ this -> isPublic ( ) ? 'public' : null ) ; } | Copy the local file to Storage |
23,603 | protected function utilGitPull ( ) { foreach ( File :: directories ( plugins_path ( ) ) as $ authorDir ) { foreach ( File :: directories ( $ authorDir ) as $ pluginDir ) { if ( ! File :: isDirectory ( $ pluginDir . '/.git' ) ) continue ; $ exec = 'cd ' . $ pluginDir . ' && ' ; $ exec .= 'git pull 2>&1' ; echo 'Updating... | This command requires the git binary to be installed . |
23,604 | public function makeConfig ( $ configFile = [ ] , $ requiredConfig = [ ] ) { if ( ! $ configFile ) { $ configFile = [ ] ; } if ( is_object ( $ configFile ) ) { $ config = $ configFile ; } elseif ( is_array ( $ configFile ) ) { $ config = $ this -> makeConfigFromArray ( $ configFile ) ; } else { if ( isset ( $ this -> c... | Reads the contents of the supplied file and applies it to this object . |
23,605 | public function makeConfigFromArray ( $ configArray = [ ] ) { $ object = new stdClass ; if ( ! is_array ( $ configArray ) ) { return $ object ; } foreach ( $ configArray as $ name => $ value ) { $ _name = camel_case ( $ name ) ; $ object -> { $ name } = $ object -> { $ _name } = $ value ; } return $ object ; } | Makes a config object from an array making the first level keys properties a new object . Property values are converted to camelCase and are not set if one already exists . |
23,606 | public function getConfigPath ( $ fileName , $ configPath = null ) { if ( ! isset ( $ this -> configPath ) ) { $ this -> configPath = $ this -> guessConfigPath ( ) ; } if ( ! $ configPath ) { $ configPath = $ this -> configPath ; } $ fileName = File :: symbolizePath ( $ fileName ) ; if ( File :: isLocalPath ( $ fileNam... | Locates a file based on it s definition . If the file starts with the ~ symbol it will be returned in context of the application base path otherwise it will be returned in context of the config path . |
23,607 | public function mergeConfig ( $ configA , $ configB ) { $ configA = $ this -> makeConfig ( $ configA ) ; $ configB = $ this -> makeConfig ( $ configB ) ; return ( object ) array_merge ( ( array ) $ configA , ( array ) $ configB ) ; } | Merges two configuration sources either prepared or not and returns them as a single configuration object . |
23,608 | public function findByFile ( $ fileName , $ parameters = [ ] ) { if ( ! strlen ( File :: extension ( $ fileName ) ) ) { $ fileName .= '.htm' ; } $ router = $ this -> getRouterObject ( ) ; return $ router -> url ( $ fileName , $ parameters ) ; } | Finds a URL by it s page . Returns the URL route for linking to the page and uses the supplied parameters in it s address . |
23,609 | protected function getRouterObject ( ) { if ( $ this -> routerObj !== null ) { return $ this -> routerObj ; } $ router = new RainRouter ( ) ; foreach ( $ this -> getUrlMap ( ) as $ pageInfo ) { $ router -> route ( $ pageInfo [ 'file' ] , $ pageInfo [ 'pattern' ] ) ; } $ router -> sortRules ( ) ; return $ this -> router... | Autoloads the URL map only allowing a single execution . |
23,610 | protected function getCachedUrlFileName ( $ url , & $ urlList ) { $ key = $ this -> getUrlListCacheKey ( ) ; $ urlList = Cache :: get ( $ key , false ) ; if ( $ urlList && ( $ urlList = @ unserialize ( @ base64_decode ( $ urlList ) ) ) && is_array ( $ urlList ) && array_key_exists ( $ url , $ urlList ) ) { return $ url... | Tries to load a page file name corresponding to a specified URL from the cache . |
23,611 | protected function makeSessionId ( ) { $ controller = property_exists ( $ this , 'controller' ) && $ this -> controller ? $ this -> controller : $ this ; $ uniqueId = method_exists ( $ this , 'getId' ) ? $ this -> getId ( ) : $ controller -> getId ( ) ; $ rootNamespace = Str :: getClassId ( Str :: getClassNamespace ( S... | Returns a unique session identifier for this widget and controller action . |
23,612 | public function listFormWidgets ( ) { if ( $ this -> formWidgets === null ) { $ this -> formWidgets = [ ] ; foreach ( $ this -> formWidgetCallbacks as $ callback ) { $ callback ( $ this ) ; } $ plugins = $ this -> pluginManager -> getPlugins ( ) ; foreach ( $ plugins as $ plugin ) { if ( ! is_array ( $ widgets = $ plug... | Returns a list of registered form widgets . |
23,613 | public function registerFormWidget ( $ className , $ widgetInfo = null ) { if ( ! is_array ( $ widgetInfo ) ) { $ widgetInfo = [ 'code' => $ widgetInfo ] ; } $ widgetCode = $ widgetInfo [ 'code' ] ?? null ; if ( ! $ widgetCode ) { $ widgetCode = Str :: getClassId ( $ className ) ; } $ this -> formWidgets [ $ className ... | Registers a single form widget . |
23,614 | public function resolveFormWidget ( $ name ) { if ( $ this -> formWidgets === null ) { $ this -> listFormWidgets ( ) ; } $ hints = $ this -> formWidgetHints ; if ( isset ( $ hints [ $ name ] ) ) { return $ hints [ $ name ] ; } $ _name = Str :: normalizeClassName ( $ name ) ; if ( isset ( $ this -> formWidgets [ $ _name... | Returns a class name from a form widget code Normalizes a class name or converts an code to its class name . |
23,615 | public function listReportWidgets ( ) { if ( $ this -> reportWidgets === null ) { $ this -> reportWidgets = [ ] ; foreach ( $ this -> reportWidgetCallbacks as $ callback ) { $ callback ( $ this ) ; } $ plugins = $ this -> pluginManager -> getPlugins ( ) ; foreach ( $ plugins as $ plugin ) { if ( ! is_array ( $ widgets ... | Returns a list of registered report widgets . |
23,616 | protected function getMigrationFileName ( Filesystem $ filesystem ) : string { $ timestamp = date ( 'Y_m_d_His' ) ; return Collection :: make ( $ this -> app -> databasePath ( ) . DIRECTORY_SEPARATOR . 'migrations' . DIRECTORY_SEPARATOR ) -> flatMap ( function ( $ path ) use ( $ filesystem ) { return $ filesystem -> gl... | Returns existing migration file if found else uses the current timestamp . |
23,617 | public function getPermissions ( array $ params = [ ] ) : Collection { if ( $ this -> permissions === null ) { $ this -> permissions = $ this -> cache -> remember ( self :: $ cacheKey , self :: $ cacheExpirationTime , function ( ) { return $ this -> getPermissionClass ( ) -> with ( 'roles' ) -> get ( ) ; } ) ; } $ perm... | Get the permissions based on the passed params . |
23,618 | public function removeRole ( $ role ) { $ this -> roles ( ) -> detach ( $ this -> getStoredRole ( $ role ) ) ; $ this -> load ( 'roles' ) ; return $ this ; } | Revoke the given role from the model . |
23,619 | public function scopePermission ( Builder $ query , $ permissions ) : Builder { $ permissions = $ this -> convertToPermissionModels ( $ permissions ) ; $ rolesWithPermissions = array_unique ( array_reduce ( $ permissions , function ( $ result , $ permission ) { return array_merge ( $ result , $ permission -> roles -> a... | Scope the model query to certain permissions only . |
23,620 | public function hasAnyPermission ( ... $ permissions ) : bool { if ( is_array ( $ permissions [ 0 ] ) ) { $ permissions = $ permissions [ 0 ] ; } foreach ( $ permissions as $ permission ) { if ( $ this -> checkPermissionTo ( $ permission ) ) { return true ; } } return false ; } | Determine if the model has any of the given permissions . |
23,621 | public function getPermissionsViaRoles ( ) : Collection { return $ this -> load ( 'roles' , 'roles.permissions' ) -> roles -> flatMap ( function ( $ role ) { return $ role -> permissions ; } ) -> sort ( ) -> values ( ) ; } | Return all the permissions the model has via roles . |
23,622 | public function getAllPermissions ( ) : Collection { $ permissions = $ this -> permissions ; if ( $ this -> roles ) { $ permissions = $ permissions -> merge ( $ this -> getPermissionsViaRoles ( ) ) ; } return $ permissions -> sort ( ) -> values ( ) ; } | Return all the permissions the model has both directly and via roles . |
23,623 | public function register ( $ container ) { if ( ! isset ( $ container [ 'environment' ] ) ) { $ container [ 'environment' ] = function ( ) { return new Environment ( $ _SERVER ) ; } ; } if ( ! isset ( $ container [ 'request' ] ) ) { $ container [ 'request' ] = function ( $ container ) { return Request :: createFromEnvi... | Register Slim s default services . |
23,624 | public function setCacheFile ( $ cacheFile ) { if ( ! is_string ( $ cacheFile ) && $ cacheFile !== false ) { throw new InvalidArgumentException ( 'Router cache file must be a string or false' ) ; } if ( $ cacheFile && file_exists ( $ cacheFile ) && ! is_readable ( $ cacheFile ) ) { throw new RuntimeException ( sprintf ... | Set path to fast route cache file . If this is false then route caching is disabled . |
23,625 | public function urlFor ( $ name , array $ data = [ ] , array $ queryParams = [ ] ) { $ url = $ this -> relativePathFor ( $ name , $ data , $ queryParams ) ; if ( $ this -> basePath ) { $ url = $ this -> basePath . $ url ; } return $ url ; } | Build the path for a named route including the base path |
23,626 | public function fullUrlFor ( UriInterface $ uri , $ routeName , array $ data = [ ] , array $ queryParams = [ ] ) { $ path = $ this -> urlFor ( $ routeName , $ data , $ queryParams ) ; $ scheme = $ uri -> getScheme ( ) ; $ authority = $ uri -> getAuthority ( ) ; $ protocol = ( $ scheme ? $ scheme . ':' : '' ) . ( $ auth... | Get fully qualified URL for named route |
23,627 | protected function attach ( $ newStream ) { if ( is_resource ( $ newStream ) === false ) { throw new InvalidArgumentException ( __METHOD__ . ' argument must be a valid PHP resource' ) ; } if ( $ this -> isAttached ( ) === true ) { $ this -> detach ( ) ; } $ this -> stream = $ newStream ; } | Attach new resource to this object . |
23,628 | public function isEmpty ( ) { return in_array ( $ this -> getStatusCode ( ) , [ StatusCode :: HTTP_NO_CONTENT , StatusCode :: HTTP_RESET_CONTENT , StatusCode :: HTTP_NOT_MODIFIED ] ) ; } | Is this response empty? |
23,629 | public function isRedirect ( ) { return in_array ( $ this -> getStatusCode ( ) , [ StatusCode :: HTTP_MOVED_PERMANENTLY , StatusCode :: HTTP_FOUND , StatusCode :: HTTP_SEE_OTHER , StatusCode :: HTTP_TEMPORARY_REDIRECT , StatusCode :: HTTP_PERMANENT_REDIRECT ] ) ; } | Is this response a redirect? |
23,630 | public function getParsedBodyParam ( $ key , $ default = null ) { $ postParams = $ this -> getParsedBody ( ) ; $ result = $ default ; if ( is_array ( $ postParams ) && isset ( $ postParams [ $ key ] ) ) { $ result = $ postParams [ $ key ] ; } elseif ( is_object ( $ postParams ) && property_exists ( $ postParams , $ key... | Fetch parameter value from request body . |
23,631 | public function redirect ( $ from , $ to , $ status = 302 ) { $ handler = function ( $ request , ResponseInterface $ response ) use ( $ to , $ status ) { return $ response -> withHeader ( 'Location' , ( string ) $ to ) -> withStatus ( $ status ) ; } ; return $ this -> get ( $ from , $ handler ) ; } | Add a route that sends an HTTP redirect |
23,632 | protected function isEmptyResponse ( ResponseInterface $ response ) { if ( method_exists ( $ response , 'isEmpty' ) ) { return $ response -> isEmpty ( ) ; } return in_array ( $ response -> getStatusCode ( ) , [ 204 , 205 , 304 ] ) ; } | Helper method which returns true if the provided response must not output a body and false if the response could have a body . |
23,633 | public function set ( $ key , $ value ) { if ( ! is_array ( $ value ) ) { $ value = [ $ value ] ; } parent :: set ( $ this -> normalizeKey ( $ key ) , [ 'value' => $ value , 'originalKey' => $ key ] ) ; } | Set HTTP header value |
23,634 | protected function seedMiddlewareStack ( callable $ kernel = null ) { if ( ! is_null ( $ this -> tip ) ) { throw new RuntimeException ( 'MiddlewareStack can only be seeded once.' ) ; } if ( $ kernel === null ) { $ kernel = $ this ; } $ this -> tip = $ kernel ; } | Seed middleware stack with first callable |
23,635 | protected function renderHtmlExceptionOrError ( $ exception ) { if ( ! $ exception instanceof Exception && ! $ exception instanceof \ Error ) { throw new RuntimeException ( "Unexpected type. Expected Exception or Error." ) ; } $ html = sprintf ( '<div><strong>Type:</strong> %s</div>' , get_class ( $ exception ) ) ; if ... | Render exception or error as HTML . |
23,636 | public function void ( ) { $ json = array ( ) ; $ this -> load -> language ( 'extension/payment/pp_express_order' ) ; if ( isset ( $ this -> request -> get [ 'order_id' ] ) ) { $ order_id = $ this -> request -> get [ 'order_id' ] ; } else { $ order_id = 0 ; } $ this -> load -> model ( 'extension/payment/pp_express' ) ;... | used to void an authorised payment |
23,637 | public function after ( & $ route , & $ args , & $ output ) { $ data = $ this -> language -> get ( 'backup' ) ; if ( is_array ( $ data ) ) { foreach ( $ data as $ key => $ value ) { $ this -> language -> set ( $ key , $ value ) ; } } } | 2 . After controller load restore old language data |
23,638 | public function toArray ( ) { $ array = $ this -> properties ; $ array [ 'title' ] = $ this -> title ; if ( $ this -> allDay ) { $ format = 'Y-m-d' ; } else { $ format = 'c' ; } $ array [ 'start' ] = $ this -> start -> format ( $ format ) ; if ( isset ( $ this -> end ) ) { $ array [ 'end' ] = $ this -> end -> format ( ... | Converts this Event object back to a plain data array to be used for generating JSON |
23,639 | public function getFeatureImportances ( ) : array { $ sum = [ ] ; foreach ( $ this -> classifiers as $ tree ) { $ importances = $ tree -> getFeatureImportances ( ) ; foreach ( $ importances as $ column => $ importance ) { if ( array_key_exists ( $ column , $ sum ) ) { $ sum [ $ column ] += $ importance ; } else { $ sum... | This will return an array including an importance value for each column in the given dataset . Importance values for a column is the average importance of that column in all trees in the forest |
23,640 | private function getIdentity ( ) : self { $ array = array_fill ( 0 , $ this -> rows , array_fill ( 0 , $ this -> columns , 0 ) ) ; for ( $ i = 0 ; $ i < $ this -> rows ; ++ $ i ) { $ array [ $ i ] [ $ i ] = 1 ; } return new self ( $ array , false ) ; } | Returns diagonal identity matrix of the same size of this matrix |
23,641 | private function getSamplesMatrix ( ) : Matrix { $ samples = [ ] ; foreach ( $ this -> samples as $ sample ) { array_unshift ( $ sample , 1 ) ; $ samples [ ] = $ sample ; } return new Matrix ( $ samples ) ; } | Add one dimension for intercept calculation . |
23,642 | protected function output ( array $ sample ) { $ sum = 0 ; foreach ( $ this -> weights as $ index => $ w ) { if ( $ index == 0 ) { $ sum += $ w ; } else { $ sum += $ w * $ sample [ $ index - 1 ] ; } } return $ sum ; } | Calculates net output of the network as a float value for the given input |
23,643 | protected function getKernel ( ) : Closure { switch ( $ this -> kernel ) { case self :: KERNEL_LINEAR : return function ( $ x , $ y ) { return Matrix :: dot ( $ x , $ y ) [ 0 ] ; } ; case self :: KERNEL_RBF : $ dist = new Euclidean ( ) ; return function ( $ x , $ y ) use ( $ dist ) { return exp ( - $ this -> gamma * $ ... | Returns the callable kernel function |
23,644 | protected function getNewDirection ( array $ theta , float $ beta , array $ d ) : array { $ grad = $ this -> gradient ( $ theta ) ; return MP :: add ( MP :: muls ( $ grad , - 1 ) , MP :: muls ( $ d , $ beta ) ) ; } | Calculates the new conjugate direction |
23,645 | public function setColumnNames ( array $ names ) { if ( $ this -> featureCount !== 0 && count ( $ names ) !== $ this -> featureCount ) { throw new InvalidArgumentException ( sprintf ( 'Length of the given array should be equal to feature count %s' , $ this -> featureCount ) ) ; } $ this -> columnNames = $ names ; retur... | A string array to represent columns . Useful when HTML output or column importances are desired to be inspected . |
23,646 | protected function getSplitNodesByColumn ( int $ column , DecisionTreeLeaf $ node ) : array { if ( $ node -> isTerminal ) { return [ ] ; } $ nodes = [ ] ; if ( $ node -> columnIndex === $ column ) { $ nodes [ ] = $ node ; } $ lNodes = [ ] ; $ rNodes = [ ] ; if ( $ node -> leftLeaf !== null ) { $ lNodes = $ this -> getS... | Collects and returns an array of internal nodes that use the given column as a split criterion |
23,647 | public static function oneWayF ( array $ samples ) : array { $ classes = count ( $ samples ) ; if ( $ classes < 2 ) { throw new InvalidArgumentException ( 'The array must have at least 2 elements' ) ; } $ samplesPerClass = array_map ( function ( array $ class ) : int { return count ( $ class ) ; } , $ samples ) ; $ all... | The one - way ANOVA tests the null hypothesis that 2 or more groups have the same population mean . The test is applied to samples from two or more groups possibly with differing sizes . |
23,648 | private function calculateStatistics ( string $ label , array $ samples ) : void { $ this -> std [ $ label ] = array_fill ( 0 , $ this -> featureCount , 0 ) ; $ this -> mean [ $ label ] = array_fill ( 0 , $ this -> featureCount , 0 ) ; $ this -> dataType [ $ label ] = array_fill ( 0 , $ this -> featureCount , self :: C... | Calculates vital statistics for each label & feature . Stores these values in private array in order to avoid repeated calculation |
23,649 | private function getSamplesByLabel ( string $ label ) : array { $ samples = [ ] ; for ( $ i = 0 ; $ i < $ this -> sampleCount ; ++ $ i ) { if ( $ this -> targets [ $ i ] == $ label ) { $ samples [ ] = $ this -> samples [ $ i ] ; } } return $ samples ; } | Return samples belonging to specific label |
23,650 | protected function runTraining ( array $ samples , array $ targets ) : void { $ callback = $ this -> getCostFunction ( ) ; switch ( $ this -> trainingType ) { case self :: BATCH_TRAINING : $ this -> runGradientDescent ( $ samples , $ targets , $ callback , true ) ; return ; case self :: ONLINE_TRAINING : $ this -> runG... | Adapts the weights with respect to given samples and targets by use of selected solver |
23,651 | protected function runConjugateGradient ( array $ samples , array $ targets , Closure $ gradientFunc ) : void { if ( $ this -> optimizer === null ) { $ this -> optimizer = ( new ConjugateGradient ( $ this -> featureCount ) ) -> setMaxIterations ( $ this -> maxIterations ) ; } $ this -> weights = $ this -> optimizer -> ... | Executes Conjugate Gradient method to optimize the weights of the LogReg model |
23,652 | protected function getBestClassifier ( ) : Classifier { $ ref = new ReflectionClass ( $ this -> baseClassifier ) ; $ classifier = count ( $ this -> classifierOptions ) === 0 ? $ ref -> newInstance ( ) : $ ref -> newInstanceArgs ( $ this -> classifierOptions ) ; if ( $ classifier instanceof WeightedClassifier ) { $ clas... | Returns the classifier with the lowest error rate with the consideration of current sample weights |
23,653 | protected function resample ( ) : array { $ weights = $ this -> weights ; $ std = StandardDeviation :: population ( $ weights ) ; $ mean = Mean :: arithmetic ( $ weights ) ; $ min = min ( $ weights ) ; $ minZ = ( int ) round ( ( $ min - $ mean ) / $ std ) ; $ samples = [ ] ; $ targets = [ ] ; foreach ( $ weights as $ i... | Resamples the dataset in accordance with the weights and returns the new dataset |
23,654 | public static function covarianceMatrix ( array $ data , ? array $ means = null ) : array { $ n = count ( $ data [ 0 ] ) ; if ( $ means === null ) { $ means = [ ] ; for ( $ i = 0 ; $ i < $ n ; ++ $ i ) { $ means [ ] = Mean :: arithmetic ( array_column ( $ data , $ i ) ) ; } } $ cov = [ ] ; for ( $ i = 0 ; $ i < $ n ; +... | Returns the covariance matrix of n - dimensional data |
23,655 | public function getRules ( ) : array { if ( count ( $ this -> large ) === 0 ) { $ this -> large = $ this -> apriori ( ) ; } if ( count ( $ this -> rules ) > 0 ) { return $ this -> rules ; } $ this -> rules = [ ] ; $ this -> generateAllRules ( ) ; return $ this -> rules ; } | Get all association rules which are generated for every k - length frequent item set . |
23,656 | private function generateRules ( array $ frequent ) : void { foreach ( $ this -> antecedents ( $ frequent ) as $ antecedent ) { $ confidence = $ this -> confidence ( $ frequent , $ antecedent ) ; if ( $ this -> confidence <= $ confidence ) { $ consequent = array_values ( array_diff ( $ frequent , $ antecedent ) ) ; $ t... | Generate confident rules for frequent item set . |
23,657 | private function items ( ) : array { $ items = [ ] ; foreach ( $ this -> samples as $ sample ) { foreach ( $ sample as $ item ) { if ( ! in_array ( $ item , $ items , true ) ) { $ items [ ] = $ item ; } } } return array_map ( function ( $ entry ) { return [ $ entry ] ; } , $ items ) ; } | Calculates frequent k = 1 item sets . |
23,658 | private function frequent ( array $ samples ) : array { return array_values ( array_filter ( $ samples , function ( $ entry ) { return $ this -> support ( $ entry ) >= $ this -> support ; } ) ) ; } | Returns frequent item sets only . |
23,659 | private function contains ( array $ system , array $ set ) : bool { return ( bool ) array_filter ( $ system , function ( $ entry ) use ( $ set ) { return $ this -> equals ( $ entry , $ set ) ; } ) ; } | Returns true if set is an element of system . |
23,660 | private function equals ( array $ set1 , array $ set2 ) : bool { return array_diff ( $ set1 , $ set2 ) == array_diff ( $ set2 , $ set1 ) ; } | Returns true if string representation of items does not differ . |
23,661 | public function fit ( array $ data , array $ classes ) : array { $ this -> labels = $ this -> getLabels ( $ classes ) ; $ this -> means = $ this -> calculateMeans ( $ data , $ classes ) ; $ sW = $ this -> calculateClassVar ( $ data , $ classes ) ; $ sB = $ this -> calculateClassCov ( ) ; $ S = $ sW -> inverse ( ) -> mu... | Trains the algorithm to transform the given data to a lower dimensional space . |
23,662 | protected function getBestNumericalSplit ( array $ samples , array $ targets , int $ col ) : array { $ values = array_column ( $ samples , $ col ) ; $ minValue = min ( $ values ) ; $ maxValue = max ( $ values ) ; $ stepSize = ( $ maxValue - $ minValue ) / $ this -> numSplitCount ; $ split = [ ] ; foreach ( [ '<=' , '>'... | Determines best split point for the given column |
23,663 | protected function calculateErrorRate ( array $ targets , float $ threshold , string $ operator , array $ values ) : array { $ wrong = 0.0 ; $ prob = [ ] ; $ leftLabel = $ this -> binaryLabels [ 0 ] ; $ rightLabel = $ this -> binaryLabels [ 1 ] ; foreach ( $ values as $ index => $ value ) { if ( Comparison :: compare (... | Calculates the ratio of wrong predictions based on the new threshold value given as the parameter |
23,664 | protected function predictProbability ( array $ sample , $ label ) : float { $ predicted = $ this -> predictSampleBinary ( $ sample ) ; if ( ( string ) $ predicted == ( string ) $ label ) { return $ this -> prob [ $ label ] ; } return 0.0 ; } | Returns the probability of the sample of belonging to the given label |
23,665 | public function train ( array $ samples , array $ targets ) : void { $ this -> reset ( ) ; $ this -> trainByLabel ( $ samples , $ targets ) ; } | Train a binary classifier in the OvR style |
23,666 | public function reset ( ) : void { $ this -> classifiers = [ ] ; $ this -> allLabels = [ ] ; $ this -> costValues = [ ] ; $ this -> resetBinary ( ) ; } | Resets the classifier and the vars internally used by OneVsRest to create multiple classifiers . |
23,667 | protected function gradient ( array $ theta ) : array { $ costs = [ ] ; $ gradient = [ ] ; $ totalPenalty = 0 ; if ( $ this -> gradientCb === null ) { throw new InvalidOperationException ( 'Gradient callback is not defined' ) ; } foreach ( $ this -> samples as $ index => $ sample ) { $ target = $ this -> targets [ $ in... | Calculates gradient cost function and penalty term for each sample then returns them as an array of values |
23,668 | protected function reduce ( array $ data ) : array { $ m1 = new Matrix ( $ data ) ; $ m2 = new Matrix ( $ this -> eigVectors ) ; return $ m1 -> multiply ( $ m2 -> transpose ( ) ) -> toArray ( ) ; } | Returns the reduced data |
23,669 | protected function runTraining ( array $ samples , array $ targets ) : void { $ callback = function ( $ weights , $ sample , $ target ) { $ this -> weights = $ weights ; $ output = $ this -> output ( $ sample ) ; $ gradient = $ output - $ target ; $ error = $ gradient ** 2 ; return [ $ error , $ gradient ] ; } ; $ isBa... | Adapts the weights with respect to given samples and targets by use of gradient descent learning rule |
23,670 | public static function deliver ( Task $ task , $ bySendMessage = false ) { $ task -> bySendMessage = $ bySendMessage ; $ deliver = function ( ) use ( $ task , $ bySendMessage ) { $ swoole = app ( 'swoole' ) ; if ( $ bySendMessage ) { $ taskWorkerNum = isset ( $ swoole -> setting [ 'task_worker_num' ] ) ? ( int ) $ swoo... | Deliver a task |
23,671 | public function aggregateDayReport ( ) { $ rankingQueryLimit = ArchivingHelper :: getRankingQueryLimit ( ) ; ArchivingHelper :: reloadConfig ( ) ; $ this -> initActionsTables ( ) ; $ this -> archiveDayPageActions ( $ rankingQueryLimit ) ; $ this -> archiveDaySiteSearchActions ( $ rankingQueryLimit ) ; $ this -> archive... | Archives Actions reports for a Day |
23,672 | private function initActionsTables ( ) { $ this -> actionsTablesByType = array ( ) ; foreach ( Metrics :: $ actionTypes as $ type ) { $ dataTable = new DataTable ( ) ; if ( $ type === Action :: TYPE_SITE_SEARCH ) { $ maxRows = ArchivingHelper :: $ maximumRowsInDataTableSiteSearch ; } else { $ maxRows = ArchivingHelper ... | Initializes the DataTables created by the archiveDay function . |
23,673 | protected function archiveDayEntryActions ( $ rankingQueryLimit ) { $ rankingQuery = false ; if ( $ rankingQueryLimit > 0 ) { $ rankingQuery = new RankingQuery ( $ rankingQueryLimit ) ; $ rankingQuery -> setOthersLabel ( DataTable :: LABEL_SUMMARY_ROW ) ; $ rankingQuery -> addLabelColumn ( 'idaction' ) ; $ rankingQuery... | Entry actions for Page URLs and Page names |
23,674 | protected function archiveDayActionsTime ( $ rankingQueryLimit ) { $ rankingQuery = false ; if ( $ rankingQueryLimit > 0 ) { $ rankingQuery = new RankingQuery ( $ rankingQueryLimit ) ; $ rankingQuery -> setOthersLabel ( DataTable :: LABEL_SUMMARY_ROW ) ; $ rankingQuery -> addLabelColumn ( 'idaction' ) ; $ rankingQuery ... | Time per action |
23,675 | protected function insertDayReports ( ) { ArchivingHelper :: clearActionsCache ( ) ; $ this -> insertPageUrlsReports ( ) ; $ this -> insertDownloadsReports ( ) ; $ this -> insertOutlinksReports ( ) ; $ this -> insertPageTitlesReports ( ) ; $ this -> insertSiteSearchReports ( ) ; } | Records in the DB the archived reports for Page views Downloads Outlinks and Page titles |
23,676 | public function index ( ) { Piwik :: checkUserIsNotAnonymous ( ) ; Piwik :: checkUserHasSomeAdminAccess ( ) ; $ view = new View ( '@UsersManager/index' ) ; $ IdSitesAdmin = Request :: processRequest ( 'SitesManager.getSitesIdWithAdminAccess' ) ; $ idSiteSelected = 1 ; if ( count ( $ IdSitesAdmin ) > 0 ) { $ defaultWebs... | The Manage Users and Permissions Admin UI screen |
23,677 | protected function getDefaultDates ( ) { $ dates = array ( 'today' => $ this -> translator -> translate ( 'Intl_Today' ) , 'yesterday' => $ this -> translator -> translate ( 'Intl_Yesterday' ) , 'previous7' => $ this -> translator -> translate ( 'General_PreviousDays' , 7 ) , 'previous30' => $ this -> translator -> tra... | Returns the enabled dates that users can select in their User Settings page Report date to load by default |
23,678 | public function userSettings ( ) { Piwik :: checkUserIsNotAnonymous ( ) ; $ view = new View ( '@UsersManager/userSettings' ) ; $ userLogin = Piwik :: getCurrentUserLogin ( ) ; $ user = Request :: processRequest ( 'UsersManager.getUser' , array ( 'userLogin' => $ userLogin ) ) ; $ view -> userEmail = $ user [ 'email' ] ... | The User Settings admin UI screen view |
23,679 | public function anonymousSettings ( ) { Piwik :: checkUserHasSuperUserAccess ( ) ; $ view = new View ( '@UsersManager/anonymousSettings' ) ; $ view -> availableDefaultDates = $ this -> getDefaultDates ( ) ; $ this -> initViewAnonymousUserSettings ( $ view ) ; $ this -> setBasicVariablesView ( $ view ) ; return $ view -... | The Anonymous Settings admin UI screen view |
23,680 | protected function initViewAnonymousUserSettings ( $ view ) { if ( ! Piwik :: hasUserSuperUserAccess ( ) ) { return ; } $ userLogin = 'anonymous' ; $ anonymousSitesAccess = Request :: processRequest ( 'UsersManager.getSitesAccessFromUser' , array ( 'userLogin' => $ userLogin ) ) ; $ anonymousSites = array ( ) ; $ idSit... | The Super User can modify Anonymous user settings |
23,681 | public function recordUserSettings ( ) { $ response = new ResponseBuilder ( Common :: getRequestVar ( 'format' ) ) ; try { $ this -> checkTokenInUrl ( ) ; $ defaultReport = Common :: getRequestVar ( 'defaultReport' ) ; $ defaultDate = Common :: getRequestVar ( 'defaultDate' ) ; $ language = Common :: getRequestVar ( 'l... | Records settings from the User Settings page |
23,682 | public function Footer ( ) { if ( $ this -> currentPageNo > 1 ) { $ this -> SetY ( - 15 ) ; $ this -> SetFont ( $ this -> footer_font [ 0 ] , $ this -> footer_font [ 1 ] , $ this -> footer_font [ 2 ] ) ; $ this -> Cell ( 0 , 10 , $ this -> footerContent . Piwik :: translate ( 'ScheduledReports_Pagination' , array ( $ t... | Render page footer |
23,683 | public function AddPage ( $ orientation = '' , $ format = '' , $ keepmargins = false , $ tocpage = false ) { parent :: AddPage ( $ orientation ) ; $ this -> setCurrentPageNo ( ) ; } | Add page to document |
23,684 | public function getExcludedQueryParameters ( $ idSite ) { $ sitesManager = APISitesManager :: getInstance ( ) ; $ site = $ sitesManager -> getSiteFromId ( $ idSite ) ; try { return SitesManager :: getTrackerExcludedQueryParameters ( $ site ) ; } catch ( Exception $ e ) { return array ( ) ; } } | Get excluded query parameters for a site . This information is used for client side url normalization . |
23,685 | public function getFollowingPages ( $ url , $ idSite , $ period , $ date , $ segment = false ) { $ url = PageUrl :: excludeQueryParametersFromUrl ( $ url , $ idSite ) ; $ resultDataTable = new DataTable ; try { $ limitBeforeGrouping = Config :: getInstance ( ) -> General [ 'overlay_following_pages_limit' ] ; $ transiti... | Get following pages of a url . This is done on the logs - not the archives! |
23,686 | protected function _cacheContent ( ) { if ( $ this -> _content === null && $ this -> _mail ) { $ this -> _content = $ this -> _mail -> getRawContent ( $ this -> _messageNum ) ; } if ( ! $ this -> isMultipart ( ) ) { return ; } $ boundary = $ this -> getHeaderField ( 'content-type' , 'boundary' ) ; if ( ! $ boundary ) {... | Cache content and split in parts if multipart |
23,687 | public function countParts ( ) { if ( $ this -> _countParts ) { return $ this -> _countParts ; } $ this -> _countParts = count ( $ this -> _parts ) ; if ( $ this -> _countParts ) { return $ this -> _countParts ; } if ( $ this -> _mail && $ this -> _mail -> hasFetchPart ) { } $ this -> _cacheContent ( ) ; $ this -> _cou... | Count parts of a multipart part |
23,688 | public function getHeaders ( ) { if ( $ this -> _headers === null ) { if ( ! $ this -> _mail ) { $ this -> _headers = array ( ) ; } else { $ part = $ this -> _mail -> getRawHeader ( $ this -> _messageNum ) ; Zend_Mime_Decode :: splitMessage ( $ part , $ this -> _headers , $ null ) ; } } return $ this -> _headers ; } | Get all headers |
23,689 | public function getHeader ( $ name , $ format = null ) { if ( $ this -> _headers === null ) { $ this -> getHeaders ( ) ; } $ lowerName = strtolower ( $ name ) ; if ( $ this -> headerExists ( $ name ) == false ) { $ lowerName = strtolower ( preg_replace ( '%([a-z])([A-Z])%' , '\1-\2' , $ name ) ) ; if ( $ this -> header... | Get a header in specificed format |
23,690 | public function headerExists ( $ name ) { $ name = strtolower ( $ name ) ; if ( isset ( $ this -> _headers [ $ name ] ) ) { return true ; } else { return false ; } } | Check wheater the Mail part has a specific header . |
23,691 | public function check ( ) { $ currentValue = ( int ) ini_get ( $ this -> setting ) ; $ return = false ; foreach ( $ this -> requiredValues as $ key => $ requiredValue ) { $ this -> requiredValues [ $ key ] [ 'isValid' ] = version_compare ( $ currentValue , $ requiredValue [ 'requiredValue' ] , $ requiredValue [ 'operat... | Checks required values against php . ini value . |
23,692 | public static function loadIdsAction ( $ actionsNameAndType ) { foreach ( $ actionsNameAndType as & $ action ) { if ( 2 == count ( $ action ) ) { $ action [ ] = null ; } } $ actionIds = self :: queryIdsAction ( $ actionsNameAndType ) ; list ( $ queriedIds , $ fieldNamesToInsert ) = self :: processIdsToInsert ( $ action... | This function will find the idaction from the lookup table log_action given an Action name type and an optional URL Prefix . |
23,693 | public static function getIdActionFromSegment ( $ valueToMatch , $ sqlField , $ matchType , $ segmentName ) { if ( $ segmentName === 'actionType' ) { $ actionType = ( int ) $ valueToMatch ; $ valueToMatch = array ( ) ; $ sql = 'SELECT idaction FROM ' . Common :: prefixTable ( 'log_action' ) . ' WHERE type = ' . $ actio... | Convert segment expression to an action ID or an SQL expression . |
23,694 | private static function normaliseActionString ( $ actionType , $ actionString ) { $ actionString = Common :: unsanitizeInputValue ( $ actionString ) ; if ( self :: isActionTypeStoredUnsanitized ( $ actionType ) ) { return $ actionString ; } return Common :: sanitizeInputValue ( $ actionString ) ; } | This function will sanitize or not if it s needed for the specified action type |
23,695 | public static function check ( $ force = false , $ interval = null ) { if ( ! SettingsPiwik :: isAutoUpdateEnabled ( ) ) { return ; } if ( $ interval === null ) { $ interval = self :: CHECK_INTERVAL ; } $ lastTimeChecked = Option :: get ( self :: LAST_TIME_CHECKED ) ; if ( $ force || $ lastTimeChecked === false || time... | Check for a newer version |
23,696 | public static function isNewestVersionAvailable ( ) { $ latestVersion = self :: getLatestVersion ( ) ; if ( ! empty ( $ latestVersion ) && version_compare ( Version :: VERSION , $ latestVersion ) == - 1 ) { return $ latestVersion ; } return false ; } | Returns version number of a newer Piwik release . |
23,697 | public function next ( ) { if ( $ this -> _skipNextIteration ) { $ this -> _skipNextIteration = false ; return ; } next ( $ this -> _data ) ; $ this -> _index ++ ; } | Defined by Iterator interface |
23,698 | public function setExtend ( $ extendingSection , $ extendedSection = null ) { if ( $ extendedSection === null && isset ( $ this -> _extends [ $ extendingSection ] ) ) { unset ( $ this -> _extends [ $ extendingSection ] ) ; } else if ( $ extendedSection !== null ) { $ this -> _extends [ $ extendingSection ] = $ extended... | Set an extend for Zend_Config_Writer |
23,699 | protected function _loadFileErrorHandler ( $ errno , $ errstr , $ errfile , $ errline ) { if ( $ this -> _loadFileErrorStr === null ) { $ this -> _loadFileErrorStr = $ errstr ; } else { $ this -> _loadFileErrorStr .= ( PHP_EOL . $ errstr ) ; } } | Handle any errors from simplexml_load_file or parse_ini_file |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.