| 234 | self.eps = 0.1 |
| 235 | |
| 236 | class model(Structure): |
| 237 | _names = ["param", "nr_class", "nr_feature", "w", "label", "bias"] |
| 238 | _types = [parameter, c_int, c_int, POINTER(c_double), POINTER(c_int), c_double] |
| 239 | _fields_ = genFields(_names, _types) |
| 240 | |
| 241 | def __init__(self): |
| 242 | self.__createfrom__ = 'python' |
| 243 | |
| 244 | def __del__(self): |
| 245 | # free memory created by C to avoid memory leak |
| 246 | if hasattr(self, '__createfrom__') and self.__createfrom__ == 'C': |
| 247 | liblinear.free_and_destroy_model(pointer(self)) |
| 248 | |
| 249 | def get_nr_feature(self): |
| 250 | return liblinear.get_nr_feature(self) |
| 251 | |
| 252 | def get_nr_class(self): |
| 253 | return liblinear.get_nr_class(self) |
| 254 | |
| 255 | def get_labels(self): |
| 256 | nr_class = self.get_nr_class() |
| 257 | labels = (c_int * nr_class)() |
| 258 | liblinear.get_labels(self, labels) |
| 259 | return labels[:nr_class] |
| 260 | |
| 261 | def is_probability_model(self): |
| 262 | return (liblinear.check_probability_model(self) == 1) |
| 263 | |
| 264 | def toPyModel(model_ptr): |
| 265 | """ |
nothing calls this directly
no test coverage detected
searching dependent graphs…