Пример #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)
Пример #2
0
def is_logisticregression(clf):
    """Test if classifier can be ported"""
    return check_type(clf, 'LogisticRegression')
Пример #3
0
def is_svm(clf):
    """Test if classifier can be ported"""
    return check_type(clf, 'SVC', 'OneClassSVM')
Пример #4
0
def is_principalfft(clf):
    """Test if classifier can be ported"""
    return check_type(clf, 'PrincipalFFT') or check_type(clf, 'KFFT')
Пример #5
0
def is_gaussiannb(clf):
    """Test if classifier can be ported"""
    return check_type(clf, 'GaussianNB')
Пример #6
0
def is_randomforest(clf):
    """Test if classifier can be ported"""
    return check_type(clf, 'RandomForestClassifier')
Пример #7
0
def is_pca(clf):
    """Test if classifier can be ported"""
    return check_type(clf, 'PCA')
Пример #8
0
def is_linear_regression(clf):
    """Test if classifier can be ported"""
    return check_type(clf, 'LinearRegression')
Пример #9
0
def is_xgboost(clf):
    """Test if classifier can be ported"""
    return check_type(clf, 'XGBClassifier')
Пример #10
0
def is_rvm(clf):
    """Test if classifier can be ported"""
    return check_type(clf, 'RVC')
Пример #11
0
def is_sefr(clf):
    """Test if classifier can be ported"""
    return check_type(clf, 'SEFR')
Пример #12
0
def is_decisiontree(clf):
    """Test if classifier can be ported"""
    return check_type(clf, 'DecisionTreeClassifier')