Exemplo n.º 1
0
def port_svm(clf, **kwargs):
    """Port a SVC / OneClassSVC classifier"""
    assert isinstance(clf.gamma, float), 'You probably didn\'t set an explicit value for gamma: 0.001 is a good default'

    support_v = clf.support_vectors_
    n_classes = len(clf.n_support_)

    return jinja('svm/svm.jinja', {
        'kernel': {
            'type': clf.kernel,
            'gamma': clf.gamma,
            'coef0': clf.coef0,
            'degree': clf.degree
        },
        'sizes': {
            'features': len(support_v[0]),
            'vectors': len(support_v),
            'classes': n_classes,
            'decisions': n_classes * (n_classes - 1) // 2,
            'supports': clf.n_support_
        },
        'arrays': {
            'supports': support_v,
            'intercepts': clf.intercept_,
            'coefs': clf.dual_coef_
        }
    }, {
        'classname': 'OneClassSVM' if check_type(clf, 'OneClassSVM') else 'SVM'
    }, **kwargs)
Exemplo n.º 2
0
def is_logisticregression(clf):
    """Test if classifier can be ported"""
    return check_type(clf, 'LogisticRegression')
Exemplo n.º 3
0
def is_svm(clf):
    """Test if classifier can be ported"""
    return check_type(clf, 'SVC', 'OneClassSVM')
Exemplo n.º 4
0
def is_principalfft(clf):
    """Test if classifier can be ported"""
    return check_type(clf, 'PrincipalFFT') or check_type(clf, 'KFFT')
Exemplo n.º 5
0
def is_gaussiannb(clf):
    """Test if classifier can be ported"""
    return check_type(clf, 'GaussianNB')
Exemplo n.º 6
0
def is_randomforest(clf):
    """Test if classifier can be ported"""
    return check_type(clf, 'RandomForestClassifier')
Exemplo n.º 7
0
def is_pca(clf):
    """Test if classifier can be ported"""
    return check_type(clf, 'PCA')
Exemplo n.º 8
0
def is_linear_regression(clf):
    """Test if classifier can be ported"""
    return check_type(clf, 'LinearRegression')
Exemplo n.º 9
0
def is_xgboost(clf):
    """Test if classifier can be ported"""
    return check_type(clf, 'XGBClassifier')
Exemplo n.º 10
0
def is_rvm(clf):
    """Test if classifier can be ported"""
    return check_type(clf, 'RVC')
Exemplo n.º 11
0
def is_sefr(clf):
    """Test if classifier can be ported"""
    return check_type(clf, 'SEFR')
Exemplo n.º 12
0
def is_decisiontree(clf):
    """Test if classifier can be ported"""
    return check_type(clf, 'DecisionTreeClassifier')