Least Squares & Nearest Neighbors

1.线性模板和最小平方

·线性回归也可用于简单的分类,boundary虽然简单,但模型势必不准确。

·存在问题:

ESL P13:两种场景

·scikit-learn:

LinearModel.LinearRegression()

class LinearRegression(LinearModel, RegressorMixin):
    """
    Ordinary least squares Linear Regression.

    Parameters
    ----------
    fit_intercept :(拟合截距) boolean, optional
        whether to calculate the intercept for this model. If set
        to false, no intercept will be used in calculations
        (e.g. data is expected to be already centered).

    normalize : boolean, optional, default False
        If True, the regressors X will be normalized before regression.

    copy_X : boolean, optional, default True
        If True, X will be copied; else, it may be overwritten.

    n_jobs : int, optional, default 1
        The number of jobs to use for the computation.
        If -1 all CPUs are used. This will only provide speedup for
        n_targets > 1 and sufficient large problems.

    Attributes
    ----------
    coef_ : 系数,斜率。array, shape (n_features, ) or (n_targets, n_features)
        Estimated coefficients for the linear regression problem.
        If multiple targets are passed during the fit (y 2D), this
        is a 2D array of shape (n_targets, n_features), while if only
        one target is passed, this is a 1D array of length n_features.

    intercept_ : 截距。array
        Independent term in the linear model.

2.最近邻模型

·样本之间的欧式距离

·k-nearest-neighbors:随着k的增加,分类准确率提高,错误率下降;反之亦反,但或造成过拟合。实际上有效的参数是N/k,而非k。下图表现出N/k,k,error之间的关系。

·scikit-learn:

3.二者比较

最小平方:低方差,高偏差;

k-nearest-neighbors:高方差,低偏差。

时间: 2024-11-10 17:06:44

Least Squares & Nearest Neighbors的相关文章

快速近似最近邻搜索库 FLANN - Fast Library for Approximate Nearest Neighbors

What is FLANN? FLANN is a library for performing fast approximate nearest neighbor searches in high dimensional spaces. It contains a collection of algorithms we found to work best for nearest neighbor search and a system for automatically choosing t

[C++与机器学习] k-近邻算法(K–nearest neighbors)

C++ with Machine Learning -K–nearest neighbors 我本想写C++与人工智能,但是转念一想,人工智能范围太大了,我根本介绍不完也没能力介绍完,所以还是取了他的子集.我想这应该是一个有关机器学习的系列文章,我会不定期更新文章,希望喜欢机器学习的朋友不宁赐教. 本系列特别之处是与一些实例相结合来系统的讲解有关机器学习的各种算法,由于能力和时间有限,不会向诸如Simon Haykin<<NEURAL NETWORKS>>等大块头详细的讲解某一个领

OpenCV K-d树实现之FLANN (Fast Library for Approximate Nearest Neighbors) 算法实现及解析

k-d树搜索最近点,在opencv中使用FLANN算法,其包含: 1:建树   2.查询 程序见下: #include "kdtree.h" #include <iostream> #include <iomanip> #include "cv.h" #include "highgui.h" #include <fstream> #include "cv.h" #include "

sklearn:最近邻搜索sklearn.neighbors

http://blog.csdn.net/pipisorry/article/details/53156836 ball tree k-d tree也有问题[最近邻查找算法kd-tree].矩形并不是用到这里最好的方式.偏斜的数据集会造成我们想要保持树的平衡与保持区域的正方形特性的冲突.另外,矩形甚至是正方形并不是用在这里最完美的形状,由于它的角.如果图6中的圆再大一些,即黑点距离目标点点再远一些,圆就会与左上角的矩形相交,需要多检查一个区域的点,而且那个区域是当前区域双亲结点的兄弟结点的子结点

关于机器学习和深度学习的资料

声明:转来的,原文出处:http://blog.csdn.net/achaoluo007/article/details/43564321 编者按:本文收集了百来篇关于机器学习和深度学习的资料,含各种文档,视频,源码等.而且原文也会不定期的更新,望看到文章的朋友能够学到更多. <Brief History of Machine Learning> 介绍:这是一篇介绍机器学习历史的文章,介绍很全面,从感知机.神经网络.决策树.SVM.Adaboost 到随机森林.Deep Learning. &

Awesome Machine Learning

Awesome Machine Learning  A curated list of awesome machine learning frameworks, libraries and software (by language). Inspired by awesome-php. If you want to contribute to this list (please do), send me a pull request or contact me @josephmisiti Als

计算机视觉算法与代码集锦

计算机视觉算法与代码集锦 计算机视觉是结合了传统摄影测量,现代计算机信息技术.人工智能等多学科的一个大学科,是一片开垦不足的大陆,路很远,但很多人都在跋涉! 本文转自CSDN(地址http://blog.csdn.net/whucv/article/details/7907391),是一篇很好的算法与代码总结文档,转载在此供大家学习参考. 原文如下: UIUC的Jia-Bin Huang同学收集了很多计算机视觉方面的代码,链接如下: https://netfiles.uiuc.edu/jbhua

机器学习&amp;深度学习资料分享

感谢:https://github.com/ty4z2008/Qix/blob/master/dl.md <Brief History of Machine Learning> 介绍:这是一篇介绍机器学习历史的文章,介绍很全面,从感知机.神经网络.决策树.SVM.Adaboost 到随机森林.Deep Learning. <Deep Learning in Neural Networks: An Overview> 介绍:这是瑞士人工智能实验室 Jurgen Schmidhuber

scikit-learn:class and function reference(看看你到底掌握了多少。。)

http://scikit-learn.org/stable/modules/classes.html#module-sklearn.decomposition Reference This is the class and function reference of scikit-learn. Please refer to the full user guide for further details, as the class and function raw specifications