Ejemplo n.º 1
0
    def predict_t2(self, grid_search = True):
        if self.docs == {}:
            raise ValueError("docs have not been created. call set_prediction_docs first!")

        # get features and target
        X, Y, info = self.get_feature('t2')
        
        # init svm classifier
        svm = SVM(self._model_path, "trig-theme1-2", "linear", grid_search = grid_search, class_weight = 'auto')
        svm.load()
        
        return svm.predict(X), Y, info
Ejemplo n.º 2
0
 def predict_tt(self, grid_search = True):
     """
     return prediction of given docid_list
     """
     if self.docs == {}:
         raise ValueError("docs have not been created. call set_prediction_docs first!")
     # get list of file
     #doc_ids = self.get_docid_list(docid_list_fname)
     
     # get features and target
     X, Y, info = self.get_feature('tt')
     
     # init svm classifier
     svm = SVM(self._model_path, "trig-trig", "linear", grid_search = grid_search, class_weight = 'auto')
     svm.load()
     
     return svm.predict(X), Y, info
Ejemplo n.º 3
0
    def learn_t2(self, docid_list_fname, grid_search):
        # get list of file
        doc_ids = self.get_docid_list(docid_list_fname)

        # get features and target
        X, Y = self.get_feature(doc_ids, 't2')

        # init svm classifier
        svm = SVM(self.path,
                  'trig-theme1-2',
                  'linear',
                  grid_search=grid_search,
                  class_weight='auto')
        svm.create()

        # fit training data
        svm.learn(X, Y)
Ejemplo n.º 4
0
if __name__ == '__main__':
    args = argument_parser()
    method = args.method

    train, labels, test, test_ids, classes = createDataSets()
    classifiers = []

    if method == 'MLP':
        clf = MLP(train, labels, test, test_ids, classes)
        classifiers.append(clf)
    elif method == 'regression':
        clf = Regression(train, labels, test, test_ids, classes)
        classifiers.append(clf)
    elif method == 'SVM':
        clf = SVM(train, labels, test, test_ids, classes)
        classifiers.append(clf)
    elif method == 'randomforest':
        clf = RF(train, labels, test, test_ids, classes)
        classifiers.append(clf)
    elif method == 'KNN':
        clf = KNN(train, labels, test, test_ids, classes)
        classifiers.append(clf)
    elif method == 'naive_bayes':
        clf = NB(train, labels, test, test_ids, classes)
        classifiers.append(clf)
    elif method == 'linear_discriminant_analysis':
        clf = LDA(train, labels, test, test_ids, classes)
        classifiers.append(clf)
    elif method == 'all':
        clfs = [MLP, SVM, RF, KNN, NB, LDA]