#
source:
orange/source/orange/liblinear_interface.hpp
@
10771:a99c79bb08d1

Revision 10771:a99c79bb08d1, 2.5 KB checked in by Ales Erjavec <ales.erjavec@…>, 2 years ago (diff) |
---|

Line | |
---|---|

1 | /* |

2 | This file is part of Orange. |

3 | |

4 | Copyright 1996-2010 Faculty of Computer and Information Science, University of Ljubljana |

5 | Contact: janez.demsar@fri.uni-lj.si |

6 | |

7 | Orange is free software: you can redistribute it and/or modify |

8 | it under the terms of the GNU General Public License as published by |

9 | the Free Software Foundation, either version 3 of the License, or |

10 | (at your option) any later version. |

11 | |

12 | Orange is distributed in the hope that it will be useful, |

13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |

14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |

15 | GNU General Public License for more details. |

16 | |

17 | You should have received a copy of the GNU General Public License |

18 | along with Orange. If not, see <http://www.gnu.org/licenses/>. |

19 | */ |

20 | |

21 | #ifndef LINEAR_HPP |

22 | #define LINEAR_HPP |

23 | |

24 | // LIBLINEAR header |

25 | |

26 | #include "linear.h" |

27 | |

28 | #include <map> |

29 | #include "classify.hpp" |

30 | #include "learn.hpp" |

31 | #include "orange.hpp" |

32 | #include "domain.hpp" |

33 | #include "examplegen.hpp" |

34 | #include "table.hpp" |

35 | #include "examples.hpp" |

36 | |

37 | // Alternative model save/load routines (using iostream, needed for in memory serialization) |

38 | int linear_save_model_alt(string &, model *); |

39 | model *linear_load_model_alt(string &); |

40 | |

41 | WRAPPER(ExampleTable) |

42 | |

43 | class ORANGE_API TLinearLearner : public TLearner{ |

44 | public: |

45 | __REGISTER_CLASS |

46 | |

47 | CLASSCONSTANTS(Lossfunction1_old_) enum {L2_LR, L2Loss_SVM_Dual, L2Loss_SVM, L1Loss_SVM_Dual }; //For backwards compatibility with 1.4 version. |

48 | CLASSCONSTANTS(Lossfunction1) enum {L2R_LR, L2R_L2Loss_SVC_Dual, L2R_L2Loss_SVC, L2R_L1Loss_SVC_Dual, MCSVM_CS, L1R_L2Loss_SVC, L1R_LR, L2R_LR_Dual}; |

49 | CLASSCONSTANTS(LIBLINEAR_VERSION: VERSION=180) |

50 | |

51 | int solver_type; //P(&LinearLearner_Lossfunction1) Solver type (loss function1) |

52 | float eps; //P Stopping criteria |

53 | float C; //P Regularization parameter |

54 | float bias; //P bias parameter (default -1.0 - no bias) |

55 | |

56 | TLinearLearner(); |

57 | PClassifier operator()(PExampleGenerator, const int & = 0); |

58 | }; |

59 | |

60 | class ORANGE_API TLinearClassifier : public TClassifierFD{ |

61 | public: |

62 | __REGISTER_CLASS |

63 | TLinearClassifier() {}; |

64 | TLinearClassifier(const PVariable &var, PExampleTable examples, model *_model); |

65 | ~TLinearClassifier(); |

66 | |

67 | PDistribution classDistribution(const TExample &); |

68 | TValue operator()(const TExample&); |

69 | |

70 | PFloatListList weights; //P Computed feature weights |

71 | PExampleTable examples; //P Examples used to train the classifier |

72 | float bias; //PR bias |

73 | model *getModel(){ return linmodel; } |

74 | private: |

75 | model *linmodel; |

76 | double dbias; |

77 | }; |

78 | |

79 | WRAPPER(LinearLearner) |

80 | WRAPPER(LinearClassifier) |

81 | |

82 | #endif /* LINEAR_HPP */ |

**Note:**See TracBrowser for help on using the repository browser.