<commit_before>#-*- coding: utf-8 -*-

from abc import ABCMeta, abstractmethod
import pickle
from sklearn.svm import SVC
from sklearn.metrics import classification_report
import sklearn
from sklearn import linear_model

class Classifier(object):
    __metaclass__ = ABCMeta

    @abstractmethod    
    def __init__(self, **params):
        raise NotImplementedError

    def train(self, X, y):
        self._model.fit(X, y)

    def predict(self, X):
        return self._model.predict(X)

    def predict_proba(self, X):
        return self._model.predict_proba(X)
    
    def evaluate(self, X_test, y_test):
        return classification_report(y_test, self._model.predict(X_test))
    
    def dump(self, filename):
        with open(filename, 'wb') as f:
            pickle.dump(self._model, f)


class LinearSVM(Classifier):
    
    def __init__(self, C):
        self._C = C
        self._model = SVC(kernel="linear", C=C, probability=True)
        
    
class LogisticRegression(Classifier):
    
    def __init__(self, C):
        self._C = C
        self._model = linear_model.LogisticRegression(C=C)
        

if __name__ == "__main__":
    pass
    <commit_msg>pretrained ConvNet classifier 추가<commit_after>#-*- coding: utf-8 -*-

from abc import ABCMeta, abstractmethod
import pickle
from sklearn.svm import SVC
from sklearn.metrics import classification_report
import sklearn
from sklearn import linear_model

class Classifier(object):
    __metaclass__ = ABCMeta

    @abstractmethod    
    def __init__(self, **params):
        raise NotImplementedError

    def train(self, X, y):
        self._model.fit(X, y)

    def predict(self, X):
        return self._model.predict(X)

    def predict_proba(self, X):
        return self._model.predict_proba(X)
    
    def evaluate(self, X_test, y_test):
        return classification_report(y_test, self._model.predict(X_test))
    
    def dump(self, filename):
        with open(filename, 'wb') as f:
            pickle.dump(self._model, f)


class LinearSVM(Classifier):
    
    def __init__(self, C):
        self._C = C
        self._model = SVC(kernel="linear", C=C, probability=True)
        
    
class LogisticRegression(Classifier):
    
    def __init__(self, C):
        self._C = C
        self._model = linear_model.LogisticRegression(C=C)
        

class ConvNet(Classifier):
    
    def __init__(self, model_file):
        from keras.models import load_model
        self._model = load_model(model_file)

    def train(self):
        pass
    
    def dump(self):
        pass
    
    def evaluate(self):
        pass

if __name__ == "__main__":
    pass
    
{'fraction_non_alphanumeric': 0.09803179409538229, 'fraction_numerical': 0.000757002271006813, 'mean_word_length': 2.610655737704918, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '493853', 'n_tokens_mistral': 844, 'n_tokens_neox': 832, 'n_words': 205}