zoukankan      html  css  js  c++  java
  • 第11章 支撑向量机SVM

    Support Vector Machine

     问题:如果决策边界不唯一

     

     

     

     

     

     

     

     s.t.(such that):之前都是全局最优化问题,这次是有条件的最优化问题

    hard margin svm:首先保证能正确的分类

    soft margin SVM:

     若是这种更不行了,:因此需soft margin SVM

     

     

    此时称L1正则

     scikit-learn中的SVM

     实际使用SVM:和kNN一样,要做数据标椎化处理!

    涉及距离!!!

    def plot_decision_boundary(model, axis):
        x0, x1 = np.meshgrid(
            np.linspace(axis[0], axis[1], int((axis[1] - axis[0]) * 100)).reshape(-1,1),
            np.linspace(axis[2], axis[3], int((axis[3] - axis[2]) * 100)).reshape(-1,1)
        )
        X_new = np.c_[x0.ravel(), x1.ravel()]
        y_predict = model.predict(X_new)
        zz = y_predict.reshape(x0.shape)
        from matplotlib.colors import ListedColormap
        custom_cmp = ListedColormap(['#EF9A9A', '#FFF59D', '#90CAF9'])
        plt.contourf(x0, x1, zz,cmap=custom_cmp)
    
    plot_decision_boundary(svc,axis=[-3,3,-3,3])
    plt.scatter(X_standard[y==0,0],X_standard[y==0,1])
    plt.scatter(X_standard[y==1,0],X_standard[y==1,1])
    plt.show()
    plot_decision_boundary

     什么是核函数?

     

     

     

    高斯核函数亦称径向基函数:

     

     

     

     

     scikit-learn中的高斯核函数:

     SVM思想解决回归问题

     

  • 相关阅读:
    自动化测试最新面试题和答案
    没有接口设计文档怎么做测试?
    测试岗/测试开发岗面经合集
    安卓测试常用的 ADB 命令
    面试问题集合
    springboot测试邮件发送
    swagger
    shiro 登录拦截和用户认证、资源授权
    SpringSecurity(安全框架)
    SpringBoot整合Mybatis框架
  • 原文地址:https://www.cnblogs.com/wuxiping2019/p/12769952.html
Copyright © 2011-2022 走看看