A PHP Error was encountered

Severity: 8192

Message: Function create_function() is deprecated

Filename: geshi/geshi.php

Line Number: 4698

Backtrace:

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 4698
Function: _error_handler

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 4621
Function: _optimize_regexp_list_tokens_to_string

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 1655
Function: optimize_regexp_list

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 2029
Function: optimize_keyword_group

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 2168
Function: build_parse_cache

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/Process.php
Line: 45
Function: parse_code

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/models/Pastes.php
Line: 517
Function: syntax

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/controllers/Main.php
Line: 693
Function: getPaste

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/index.php
Line: 315
Function: require_once

Untitled - Stikked
From Perl Crocodile, 5 Years ago, written in Python.
Embed
  1. class boost:
  2.     def __init__(self, tree, n_estimators = 100):
  3.         self.models = list()
  4.         self.weights = list()
  5.         self.errors = list()
  6.         self.tree = tree
  7.         self.n_estimators = n_estimators
  8.         self.sp = 0
  9.        
  10.     def predict(self, x):
  11.         res = np.zeros(x.shape[0])
  12.         for model, weight in zip(self.models, self.weights):
  13.             res += 1.0 * weight * model.predict(x)
  14.         return res
  15.    
  16.     def _static_predict(self):
  17.         return self._sp
  18.    
  19.     def add_model(self, model, weight, x):
  20.         self.models.append(model)
  21.         self.weights.append(weight)
  22.         self._sp += 1.0 * weight * model.predict(x)
  23.        
  24.     def _weighted_median(self, a, weights):
  25.         sort = np.argsort(a)
  26.         a = a[sort]
  27.         weights = weights[sort]
  28.         weights = weights / np.sum(weights)
  29.         weights = np.cumsum(weights)
  30.         for i in range(1, a.shape[0] - 1):
  31.             if weights[i - 1] <= 1/2 and weights[i + 1] >= 1/2:
  32. #                 print(a[i])
  33.                 return a[i]
  34.  
  35.     def fit(self, x, y):
  36.         m_0 = self.tree(max_depth = 2)
  37.         m_0.fit(x, y)
  38.        
  39.         self._sp = np.zeros(y.shape[0])
  40.         self.add_model(m_0, 1, x)
  41.        
  42.         for i in range(self.n_estimators):
  43. #             print('\r' + str(i))
  44.             grad = np.sign(y - self._static_predict())
  45.             a = self.tree(max_depth = 3)
  46.             a.fit(x, grad)
  47.             a_predict = a.predict(x)
  48.             old_preds = self._static_predict()
  49.            
  50.             b = self._weighted_median((y - old_preds) / a_predict, np.abs(a_predict))
  51.             self.add_model(a, b, x)
  52.            
  53.             self.errors.append(np.mean(np.abs(old_preds - y)))
  54.    
  55.     def get_errors(self):
  56.         return self.errors