zoukankan      html  css  js  c++  java
  • 眼底血管分割训练函数(SVM,Adaboost)

    # -*- coding: utf-8 -*-
    
    import numpy as np
    from sklearn import svm
    from sklearn.model_selection import train_test_split
    from sklearn.externals import joblib
    from sklearn.tree import DecisionTreeClassifier
    from sklearn.metrics import zero_one_loss
    from sklearn.ensemble import AdaBoostClassifier
    
    
    path = u'extract.txt'
    
    data0 = np.loadtxt(path,dtype = str,delimiter = ' ')
    data = np.array( [[row[i] for i in range(0, 8) if i != 7] for row in data0] )#del the last col of the array
    x = data[:,(1,2,3,4,5,6)]
    y = data[:,0]
    x = np.uint8(x)
    y = np.uint8(y)
    #y[y[:]==255]=1
    #y[y[:]==0]=-1
    #x_train, x_test, y_train, y_test = train_test_split(x, y, random_state=1, train_size=0.6)
    #clf = svm.SVC()
    """
    n_estimators = 800
    learning_rate = 1.0
    dt_stump = DecisionTreeClassifier(max_depth=12, min_samples_leaf=1)
    dt_stump.fit(x, y)
    ada_discrete = AdaBoostClassifier(
        base_estimator=dt_stump,
        learning_rate=learning_rate,
        n_estimators=n_estimators,
        algorithm="SAMME")
    ada_discrete.fit(x, y)
    """
    clf = svm.SVC(C=0.8, kernel='rbf', gamma=20, decision_function_shape='ovr')
    clf.fit(x, y.ravel())
    joblib.dump(clf, "train_model.m")
    
  • 相关阅读:
    递延收益
    企业收到政府补助的核算方法
    总额法
    发行股票手续费为什么冲减资本公积
    溢价发行
    融资筹资的区别是什么
    资本公积转增股本
    认股权证和股票期权有什么区别?
    postgresql 锁表查询语句
    生成不带版本的jar包 不影响deploy
  • 原文地址:https://www.cnblogs.com/fourmi/p/8453778.html
Copyright © 2011-2022 走看看