zoukankan      html  css  js  c++  java
  • 支持向量机 SVM

    概念

    • 将向量映射到一个更高维的空间里,在这个空间里建立有一个最大间隔超平面。在分开数据的超平面的两边建有两个互相平行的超平面,分隔超平面使两个平行超平面的距离最大化。假定平行超平面间的距离或差距越大,分类器的总误差越小。
    • 基本模型是定义在特征空间上的间隔最大的线性分类器
    • SVM的的学习算法就是求解凸二次规划的最优化算法。

    数学理论

    评估指标

    ScikitLearn 中的线性回归用法

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    from sklearn.model_selection import train_test_split
    from sklearn.svm import SVC
    X = df_feat
    y = cancer['target']

    X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3)
    model = SVC()
    model.fit(X_train, y_train)
    pred = model.predict(X_test)

    from sklearn.metrics import classification_report, confusion_matrix
    print(classification_report(y_test, pred))
    print(confusion_matrix(y_test, pred))
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    from sklearn.model_selection import train_test_split
    from sklearn.svm import SVC
    from sklearn.model_selection import GridSearchCV

    param_grid = {'C': [0.1, 1, 10, 100, 1000], 'gamma': [1, 0.1, 0.01, 0.001, 0.0001]}
    grid = GridSearchCV(SVC(), param_grid, verbose=3)

    grid.fit(X_train, y_train)
    grid.best_params_
    grid.best_estimator_
    grid_pred = grid.predict(X_test)

    print(classification_report(y_test, grid_pred))
    print(confusion_matrix(y_test, grid_pred))

    数学知识补充





  • 相关阅读:
    fastcgi与cgi的区别
    oracle启动脚本
    oracle表空间大小的限制和DB_BLOCK_SIZE的概念
    静默安装Oracle11G
    ls 指令的介绍
    cronolog日志切割catalina.out
    oracle expdp自动备份脚本
    tomcat开启自启动
    oracle listener.ora文件配置
    CentOS 7.0 上安装和配置 VNC 服务器
  • 原文地址:https://www.cnblogs.com/lijianming180/p/12041121.html
Copyright © 2011-2022 走看看