
scikit-learn
文章平均质量分 82
mmc2015
北大信科学院,关注深度强化学习。http://net.pku.edu.cn/~maohangyu/
展开
-
Scikit-learn技巧(拓展)总结
总结的很好、很全面。http://www.jianshu.com/p/516f009c0875最近看了《Python数据挖掘入门与实战》,网上有说翻译地不好的,但是说实话,我觉得这本书还是相当不错的。作者Robert Layton是sklearn的开发者之一,书中介绍了很多sklearn使用的技巧和拓展的方法。这里就书中关于sklearn的部分,还有自己学习sklearn的转载 2016-09-05 18:23:00 · 2757 阅读 · 0 评论 -
scikit-learn:加载自己的原始数据
这里不讨论加载常用的公用数据集,而是讨论加载自己的原始数据(即,实际中遇到的数据)http://scikit-learn.org/stable/modules/generated/sklearn.datasets.load_files.html#sklearn.datasets.load_filessklearn.datasets.load_files(翻译 2015-07-12 20:28:21 · 18939 阅读 · 6 评论 -
scikit-learn:从文本文件中提取特征(tf、idf)
http://scikit-learn.org/stable/tutorial/text_analytics/working_with_text_data.html昨晚写了两篇文章,明明保存了,今早却没了,只好简单的重复一下。。。1、tf:首先要解决high-dimensional sparse datasets的问题,scipy.sparse matrices 就是这样的原创 2015-07-13 07:48:40 · 4228 阅读 · 0 评论 -
scikit-learn:3.5. Validation curves: plotting scores to evaluate models
参考:http://scikit-learn.org/stable/modules/learning_curve.htmlestimator's generalization error can be decomposed in terms ofbias, variance and noise. The bias of an estimator is its avera原创 2015-07-30 09:23:56 · 2021 阅读 · 0 评论 -
scikit-learn:3. Model selection and evaluation
参考:http://scikit-learn.org/stable/model_selection.html有待翻译,敬请期待:3.1. Cross-validation: evaluating estimator performance3.1.1. Computing cross-validated metrics3.1.1.1. Obtain原创 2015-07-27 21:07:24 · 1880 阅读 · 0 评论 -
scikit-learn:4.4. Unsupervised dimensionality reduction(降维)
参考:http://scikit-learn.org/stable/modules/unsupervised_reduction.html对于高维features,常常需要在supervised之前unsupervised dimensionality reduction。下面三节的翻译会在之后附上。4.4.1. PCA: principal compo原创 2015-07-26 11:14:55 · 2063 阅读 · 0 评论 -
scikit-learn:CountVectorizer提取tf都做了什么
http://scikit-learn.org/stable/modules/generated/sklearn.feature_extraction.text.CountVectorizer.html#sklearn.feature_extraction.text.CountVectorizerclass sklearn.feature_extraction.text.C原创 2015-07-13 18:58:52 · 26244 阅读 · 8 评论 -
scikit-learn:5. 加载内置公用的数据
之前写过一篇如何加载自己的数据,参考:http://blog.youkuaiyun.com/mmc2015/article/details/46852755本篇主要写如何加载scikit-learn内置数据,参考:http://scikit-learn.org/stable/datasets/index.html#general-dataset-api重点介绍“5.7:The 20原创 2015-07-16 08:58:38 · 5491 阅读 · 0 评论 -
scikit-learn:训练分类器、预测新数据、评价分类器
http://scikit-learn.org/stable/tutorial/text_analytics/working_with_text_data.html构建分类器,以NB为例:from sklearn.naive_bayes import MultinomialNBclf = MultinomialNB().fit(X_tfidf, rawData.target)要原创 2015-07-13 08:14:59 · 9404 阅读 · 0 评论 -
scikit-learn:6. Strategies to scale computationally: bigger data
参考:http://scikit-learn.org/stable/modules/scaling_strategies.html对于examples、features(或者两者)数量很大的情况,挑战传统的方法要解决两个问题:内存和效率。办法是Out-of-core (or “external memory”) learning。有三种方法可以实现out-of-core,分别是:原创 2015-07-27 09:12:34 · 1606 阅读 · 0 评论 -
scikit-learn:4.2.3. Text feature extraction
http://scikit-learn.org/stable/modules/feature_extraction.html4.2节内容太多,因此将文本特征提取单独作为一块。1、the bag of words representation将raw data表示成长度固定的数字特征向量,scikit-learn提供了三个方式:tokenizing:给每一个token(字、词原创 2015-07-22 07:57:15 · 4269 阅读 · 0 评论 -
scikit-learn:4.1. Pipeline and FeatureUnion: combining estimators(特征与预测器结合;特征与特征结合)
http://scikit-learn.org/stable/modules/pipeline.html 1、pipeline和featureUnion是干什么的:pipeline之前已经介绍过了,结合transformer和estimator。featureUinon听名字就知道,将多个transformer的结果vector拼接成大的vector。两者的区别:前者相当原创 2015-07-21 20:29:32 · 3141 阅读 · 2 评论 -
scikit-learn:在实际项目中用到过的知识点(总结)
零、所有项目通用的:http://blog.youkuaiyun.com/mmc2015/article/details/46851245(数据集格式和预测器)http://blog.youkuaiyun.com/mmc2015/article/details/46852755(加载自己的原始数据)(适合文本分类问题的 整个语料库加载)http://blog.youkuaiyun.com/mmc2原创 2015-07-27 08:34:35 · 7156 阅读 · 4 评论 -
scikit-learn(工程中用的相对较多的模型介绍):1.4. Support Vector Machines
参考:http://scikit-learn.org/stable/modules/svm.html在实际项目中,我们真的很少用到那些简单的模型,比如LR、kNN、NB等,虽然经典,但在工程中确实不实用。今天我们关注在工程中用的相对较多的SVM。SVM功能不少:Support vector machines (SVMs) are a se原创 2015-08-04 07:33:26 · 2667 阅读 · 1 评论 -
sklearn中,RandomForest、DecisionTree、cython(spliter、builder)三个层面的fit、predict
本来有做PPT,可惜了。。。只好看这个草稿纸了。原创 2016-09-01 17:05:54 · 1097 阅读 · 0 评论 -
GBDT训练分类器时,残差是如何计算的?
大家都知道,对于回归任务,GBDT的loss=(y-pred)^2,因此残差residual=2*(y-pred)很容易理解。那么,GBDT做分类任务时,残差是怎样的呢???Gradient Boosting attempts to solve this minimization problem numerically via steepest descent,The st原创 2016-09-01 14:05:43 · 8616 阅读 · 1 评论 -
scikit-learn(工程中用的相对较多的模型介绍):1.11. Ensemble methods
参考:http://scikit-learn.org/stable/modules/ensemble.html在实际项目中,我们真的很少用到那些简单的模型,比如LR、kNN、NB等,虽然经典,但在工程中确实不实用。今天我们关注在工程中用的相对较多的Ensemble methods。Ensemble methods(集成方法)主要是综合多个esti原创 2015-08-04 08:24:16 · 15879 阅读 · 2 评论 -
sklearn源码解析:ensemble模型 零碎记录;如何看sklearn代码,以tree的feature_importance为例
最近看sklearn的源码比较多,好记性不如烂笔头啊,还是记一下吧。整体:)实现的代码非常好,模块化、多继承等写的很清楚。)predict功能通常在该模型的直接类中实现,fit通常在继承的类中实现,方便不同的子类共同引用。随机森林 和 GBDT)RandomForest的bootstrap是又放回的;GBDT则是无放回的。原创 2016-07-12 10:14:30 · 24575 阅读 · 6 评论 -
scikit-learn:class and function reference(看看你到底掌握了多少。。)
http://scikit-learn.org/stable/modules/classes.html#module-sklearn.decompositionReferenceThis is the class and function reference of scikit-learn. Please refer to the full user gui原创 2015-08-20 08:11:04 · 4439 阅读 · 0 评论 -
scikit-learn:matplotlib.pyplot常用画图功能总结(1)
参考:http://matplotlib.org/api/pyplot_api.html1、matplotlib.pyplot.plot(*args, **kwargs),最简单的沿坐标轴划线函数:下面四种格式都合法:plot(x, y) # plot x and y using default line style and colorplot(x, y,原创 2015-08-18 09:17:54 · 35950 阅读 · 0 评论 -
scikit-learn:matplotlib.pyplot常用画图功能总结(2)——多子图绘制
画图功能总结(1):http://blog.youkuaiyun.com/mmc2015/article/details/477461951、回忆之前,快速入门:# -*- coding: utf-8 -*-import numpy as npimport matplotlib.pyplot as pltx = np.linspace(0, 10, 1000)y = np.sin(x原创 2015-09-05 10:03:06 · 12821 阅读 · 0 评论 -
scikit-learn(工程中用的相对较多的模型介绍):1.14. Semi-Supervised
参考:http://scikit-learn.org/stable/modules/label_propagation.htmlThe semi-supervised estimators insklearn.semi_supervised are able to make use of this additional unlabeled data to better ca原创 2015-08-07 09:09:10 · 5430 阅读 · 0 评论 -
scikit-learn(工程中用的相对较多的模型介绍):1.12. Multiclass and multilabel algorithms
http://scikit-learn.org/stable/modules/multiclass.html在实际项目中,我们真的很少用到那些简单的模型,比如LR、kNN、NB等,虽然经典,但在工程中确实不实用。今天我们关注在工程中用的相对较多的 Multiclass and multilabel algorithms。warning:sciki原创 2015-08-07 08:27:58 · 3466 阅读 · 0 评论 -
scikit-learn(工程中用的相对较多的模型介绍):1.13. Feature selection
参考:http://scikit-learn.org/stable/modules/feature_selection.htmlThe classes in the sklearn.feature_selection module can be used for feature selection/dimensionality reduction on sample sets, e原创 2015-08-07 09:03:28 · 3764 阅读 · 0 评论 -
machine learning in coding(python):根据关键字合并多个表(构建组合feature)
三张表;train_set.csv;test_set.csv;feature.csv。三张表通过object_id关联。import pandas as pdimport numpy as np# load training and test datasetstrain = pd.read_csv('../input/train_set.csv')test = pd.re原创 2015-08-02 17:14:38 · 2339 阅读 · 0 评论 -
scikit-learn: isotonic regression(保序回归,很有意思,仅做知识点了解,但几乎没用到过)
http://scikit-learn.org/stable/auto_examples/plot_isotonic_regression.html#example-plot-isotonic-regression-py代码就不贴了,参考上面链接。给个简单的例子:问题描述:给定一个无序数字序列y,通过修改每个元素的值得到一个非递减序列 y‘ ,问如何使y和 y’原创 2015-08-16 23:22:03 · 5642 阅读 · 0 评论 -
scikit-learn:7. Computational Performance(计算效能<延迟和吞吐量>)
参考:http://scikit-learn.org/stable/modules/computational_performance.html对于有些应用,estimators的计算效能(主要指预测新样本时的延迟和吞吐量)非常关键,我们也考虑训练的效能,但由于训练可以offline,所以我们更关注预测时的效能问题。预测延迟(Prediction latency):预测一个新样本花原创 2015-07-27 20:58:12 · 1646 阅读 · 0 评论 -
scikit-learn:通过TruncatedSVD实现LSA(隐含语义分析)
http://scikit-learn.org/stable/modules/decomposition.html#lsa第2.5.2部分:2.5.2. Truncated singular value decomposition and latent semantic analysis(截断SVD和LSA/LSA)先说明:latent semantic indexing, LSI和l原创 2015-07-13 21:10:39 · 16418 阅读 · 3 评论 -
scikit-learn:2.5.矩阵因子分解问题
http://scikit-learn.org/stable/modules/decomposition.html#lsa2.5.1:PCA标准PCA:只支持批量处理incremental PCA:支持分批处理,对于内存容不下的情况很好Approximate PCA:RandomizedPCA 通过computation to an approximated e原创 2015-07-13 20:55:19 · 2782 阅读 · 0 评论 -
scikit-learn:构建文本分类的“pipeline”简化分类过程、网格搜索调参
前两篇分别将“加载数据”和“提取tf、tf-idf,进而构建分类器”,其实这个过程,vectorizer => transformer => classifier,早已被“scikit-learn provides a Pipeline class”一下就可以搞定:本篇翻译:http://scikit-learn.org/stable/tutorial/text_analytics/w翻译 2015-07-12 21:21:15 · 3266 阅读 · 6 评论 -
scikit-learn:通过Non-negative matrix factorization (NMF or NNMF)实现LSA(隐含语义分析)
之前写过两篇文章,分别是1)矩阵分解的综述:scikit-learn:2.5.矩阵因子分解问题2)关于TruncatedSVD的简单介绍:scikit-learn:通过TruncatedSVD实现LSA(隐含语义分析)今天发现NMF也是一个很好很实用的模型,就简单介绍一下,它也属于scikit-learn:2.5.矩阵因子分解问题的一部分。NMF是另一种压缩方法,前原创 2015-08-20 09:02:17 · 3043 阅读 · 0 评论 -
scikit-learn:4. 数据集预处理(clean数据、reduce降维、expand增维、generate特征提取)
本文参考:http://scikit-learn.org/stable/data_transforms.html本篇主要讲数据预处理,包括四部分:数据清洗、数据降维(PCA类)、数据增维(Kernel类)、提取自定义特征。哇哈哈,还是关注预处理比较靠谱。。。。重要的不翻译:scikit-learn providesa library of transformers, whi原创 2015-07-16 21:07:14 · 4203 阅读 · 0 评论 -
scikit-learn:4.5. Random Projection
参考:http://scikit-learn.org/stable/modules/random_projection.htmlThe sklearn.random_projection module 通过trading accuracy(可控的范围)来降维数据,提高效率。实现了两类unstructured random matrix:: Gaussian random mat原创 2015-07-26 12:47:59 · 3766 阅读 · 0 评论 -
scikit-learn:0.3. 从文本文件中提取特征(tf、tf-idf)、训练一个分类器
上一篇讲了如何加载数据。本篇参考:http://scikit-learn.org/stable/tutorial/text_analytics/working_with_text_data.html主要讲解如下部分:Extracting features from text filesTraining a classifier跑模型之前,需要将文本文件的翻译 2015-07-12 20:52:56 · 4710 阅读 · 2 评论 -
scikit-learn:0. user_guide——需要学习的所有内容
内容来自:http://scikit-learn.org/stable/index.html1. Supervised learning1.1. Generalized Linear Models1.2. Linear and quadratic discriminant analysis1.3. Kernel ridge regression1.4. Su原创 2015-07-01 08:49:11 · 1393 阅读 · 0 评论 -
scikit-learn:4.7. Pairwise metrics, Affinities and Kernels
参考:http://scikit-learn.org/stable/modules/metrics.htmlThe sklearn.metrics.pairwise submodule implements utilities to evaluate pairwise distances(样本对的距离) or affinity of sets of samples(样本集的相似度)原创 2015-07-26 16:35:39 · 2066 阅读 · 0 评论 -
scikit-learn:4.6. Kernel Approximation
参考:http://scikit-learn.org/stable/modules/kernel_approximation.html之所以使用approximate explicit feature maps compared to the kernel trick, 是因为这样便于online learning,且能够适用于大数据集。但是还是建议,如果可能,approximat原创 2015-07-26 15:36:55 · 3417 阅读 · 0 评论 -
scikit-learn(不常用,仅了解知识点):2.2. Manifold learning(流形学习)
参考:http://scikit-learn.org/stable/modules/manifold.html1、流形学习是非线性的降维方法(an approach to non-linear dimensionality reduction)。2、因为随机映射会随机损失数据内部信息;因为类似于PCA、LDA等降维方法基于线性假设,经常会损失数据内部非线性的结构信息原创 2015-08-11 08:29:09 · 3061 阅读 · 0 评论 -
scikit-learn:0.1. 数据集格式和预测器
http://scikit-learn.org/stable/tutorial/statistical_inference/settings.html1、数据集:数据集都是2维的,第一维度是“样本维”,第二维度是“特征维”。>>> from sklearn import datasets>>> iris = datasets.load_iris()>>> data =翻译 2015-07-12 16:38:30 · 3422 阅读 · 0 评论 -
scikit-learn:4.8. Transforming the prediction target (y)
参考:http://scikit-learn.org/stable/modules/preprocessing_targets.html没什么好翻译的,直接给例子。1、Label binarizationLabelBinarizer is a utility class to help create a label indicator matrix from原创 2015-07-26 17:52:44 · 1536 阅读 · 0 评论