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思想解决回归问题

     

  • 相关阅读:
    ROS+clion多节点调试
    argparse模块用法实例详解
    Python3中的bytes和str类型
    elk日志过滤文档
    centos7普通用户无法切换为root用户处理
    Hyper-V迁移方案
    中小互联网电商(电商)公司研发部门组织架构
    基于Redis实现令牌桶限流
    异步与协程
    C# 同步上下文及死锁
  • 原文地址:https://www.cnblogs.com/wuxiping2019/p/12769952.html
Copyright © 2011-2022 走看看