Evaluate for data. Parameters ---------- data : Dataset Data for the evaluating. name : string Name of the data. feval : callable or None, optional (default=None) Customized evaluation function. Should accept tw
(self, data, name, feval=None)
| 2113 | return num_trees.value |
| 2114 | |
| 2115 | def eval(self, data, name, feval=None): |
| 2116 | """Evaluate for data. |
| 2117 | |
| 2118 | Parameters |
| 2119 | ---------- |
| 2120 | data : Dataset |
| 2121 | Data for the evaluating. |
| 2122 | name : string |
| 2123 | Name of the data. |
| 2124 | feval : callable or None, optional (default=None) |
| 2125 | Customized evaluation function. |
| 2126 | Should accept two parameters: preds, eval_data, |
| 2127 | and return (eval_name, eval_result, is_higher_better) or list of such tuples. |
| 2128 | |
| 2129 | preds : list or numpy 1-D array |
| 2130 | The predicted values. |
| 2131 | eval_data : Dataset |
| 2132 | The evaluation dataset. |
| 2133 | eval_name : string |
| 2134 | The name of evaluation function (without whitespaces). |
| 2135 | eval_result : float |
| 2136 | The eval result. |
| 2137 | is_higher_better : bool |
| 2138 | Is eval result higher better, e.g. AUC is ``is_higher_better``. |
| 2139 | |
| 2140 | For multi-class task, the preds is group by class_id first, then group by row_id. |
| 2141 | If you want to get i-th row preds in j-th class, the access way is preds[j * num_data + i]. |
| 2142 | |
| 2143 | Returns |
| 2144 | ------- |
| 2145 | result : list |
| 2146 | List with evaluation results. |
| 2147 | """ |
| 2148 | if not isinstance(data, Dataset): |
| 2149 | raise TypeError("Can only eval for Dataset instance") |
| 2150 | data_idx = -1 |
| 2151 | if data is self.train_set: |
| 2152 | data_idx = 0 |
| 2153 | else: |
| 2154 | for i in range_(len(self.valid_sets)): |
| 2155 | if data is self.valid_sets[i]: |
| 2156 | data_idx = i + 1 |
| 2157 | break |
| 2158 | # need to push new valid data |
| 2159 | if data_idx == -1: |
| 2160 | self.add_valid(data, name) |
| 2161 | data_idx = self.__num_dataset - 1 |
| 2162 | |
| 2163 | return self.__inner_eval(name, data_idx, feval) |
| 2164 | |
| 2165 | def eval_train(self, feval=None): |
| 2166 | """Evaluate for training data. |