scikit-learn

小白机器学习实用笔记

两盒软妹~` 提交于 2021-01-20 10:32:07
小白机器学习实用笔记 一.什么是机器学习 机器学习项目流程 特征工程三大步骤:特征抽取、预处理、降维 数据类型 数据集 监督学习与无监督学习 二.用sklearn对特征进行提取(特征抽取) 1: 字典的文字特征提取 2:count方式提取文字特征 3:tf-idf对文字特征提取 打算利用空余时间学习python机器学习,通过写文章的方式来记录学习成果。持续更新中。。。。。 一.什么是机器学习 机器学习是一种数据科学技术,它帮助计算机从现有数据中学习,从而预测未来的行为、结果和趋势 机器学习项目流程 1.根据原始数据明确问题,该做什么 2.特征工程 3找到合适算法,进行训练预测 4模型的评估,判定效果 特征工程三大步骤:特征抽取、预处理、降维 1.特征抽取:将文字、图像等转化为数字 2.预处理:将数字转化为格式统一、符合规范的数值,并且减少特殊值 3.降维:进行数据的筛选,取出最有代表性的数据特征 数据类型 · 散 型 数 据 : 由 记 录 不 同 类 别 个 体 的 数 目 所 得 到 的 数 据 , 又 称 计 数 数 据 , 所 有 这 些 数 据 全 部 都 是 整 数 , 而 且 不 能 再 细 分 , 也 不 能 进 一 步 提 高 他 们 的 精 确 度 。 · 连 续 型 数 据 : 变 量 可 以 在 某 个 范 围 内 取 任 一 数 , 即 变 量 的 取 值

ModuleNotFoundError: No module named 'surprise'

↘锁芯ラ 提交于 2021-01-20 09:20:19
问题 I have installed scikit-surprise in Windows10. C:\Users\Cosmos Lord>pip install scikit-surprise Requirement already satisfied: scikit-surprise in c:\users\cosmos lord\appdata\roaming\python\python37\site-packages (1.1.0) Requirement already satisfied: joblib>=0.11 in c:\users\cosmos lord\appdata\roaming\python\python37\site-packages (from scikit-surprise) (0.14.0) Requirement already satisfied: numpy>=1.11.2 in c:\users\cosmos lord\appdata\roaming\python\python37\site-packages (from scikit

Accuracy given from evaluating model not equal to sklearn classification_report accuracy

£可爱£侵袭症+ 提交于 2021-01-19 08:10:24
问题 I'm using sklearn classification_report for reporting test statistics. The accuracy given by this method is 42% while model evaluation gives 93% accuracy. Which one is the real accuracy and what's the reason of this difference? Model evaluation: results = model.evaluate(test_ds.values, test_lb.values) print(results) Output: 7397/7397 [==============================] - 0s 28us/sample - loss: 0.2309 - acc: 0.9305 Report Classification: import numpy as np from sklearn.metrics import

Accuracy given from evaluating model not equal to sklearn classification_report accuracy

梦想与她 提交于 2021-01-19 08:08:38
问题 I'm using sklearn classification_report for reporting test statistics. The accuracy given by this method is 42% while model evaluation gives 93% accuracy. Which one is the real accuracy and what's the reason of this difference? Model evaluation: results = model.evaluate(test_ds.values, test_lb.values) print(results) Output: 7397/7397 [==============================] - 0s 28us/sample - loss: 0.2309 - acc: 0.9305 Report Classification: import numpy as np from sklearn.metrics import

Accuracy given from evaluating model not equal to sklearn classification_report accuracy

狂风中的少年 提交于 2021-01-19 08:08:17
问题 I'm using sklearn classification_report for reporting test statistics. The accuracy given by this method is 42% while model evaluation gives 93% accuracy. Which one is the real accuracy and what's the reason of this difference? Model evaluation: results = model.evaluate(test_ds.values, test_lb.values) print(results) Output: 7397/7397 [==============================] - 0s 28us/sample - loss: 0.2309 - acc: 0.9305 Report Classification: import numpy as np from sklearn.metrics import

Parameters are not going to custom estimator in scikit-learn GridSearchCV

醉酒当歌 提交于 2021-01-19 06:47:35
问题 I'm trying and failing to pass parameters to a custom estimator in scikit learn. I'd like the parameter lr to change during the gridsearch. Problem is that the lr parameter is not changing... The code sample is copied and updated from here (the original code did neither work for me) Any full working example of GridSearchCV with custom estimator, with changing parameters would be appreciated. I'm in ubuntu 18.10 using scikit-learn 0.20.2 from sklearn.model_selection import GridSearchCV from

Parameters are not going to custom estimator in scikit-learn GridSearchCV

为君一笑 提交于 2021-01-19 06:45:25
问题 I'm trying and failing to pass parameters to a custom estimator in scikit learn. I'd like the parameter lr to change during the gridsearch. Problem is that the lr parameter is not changing... The code sample is copied and updated from here (the original code did neither work for me) Any full working example of GridSearchCV with custom estimator, with changing parameters would be appreciated. I'm in ubuntu 18.10 using scikit-learn 0.20.2 from sklearn.model_selection import GridSearchCV from

基于 OpenCV 的图像分割

*爱你&永不变心* 提交于 2021-01-17 05:56:34
点击上方 “ 小白学视觉 ”,选择加" 星标 "或“ 置顶 ” 重磅干货,第一时间送达 本期我们将一起来实现一个有趣的问题 -图像分割的算法。 本文的示例代码可以在以下链接中找到: https://github.com/kiteco/kite-python-blog-post-code/tree/master/image-segmentation 作为我们的例子,我们将对KESM显微镜获取的图像进行分割以获取其中的血管组织。 数据科学家和医学研究人员可以将这种方法作为模板,用于更加复杂的图像的数据集(如天文数据),甚至一些非图像数据集中。由于图像在计算机中表示为矩阵,我们有一个专门的排序数据集作为基础 。 在整个处理过程中,我们将使用 Python 包,以及OpenCV、scikit 图像等几种工具。除此之外,我们还将使用 numpy ,以确保内存中的值一致存储。 主要内容 去噪 为了消除噪声,我们使用简单的中位数滤波器来移除异常值,但也可以使用一些不同的噪声去除方法或伪影去除方法。这项工件由采集系统决定(显微镜技术),可能需要复杂的算法来恢复丢失的数据。工件通常分为两类: 1. 模糊或焦点外区域 2. 不平衡的前景和背景(使用直方图修改正确) 分割 对于本文,我们使用Otsu 的方法分割,使用中位数滤波器平滑图像后,然后验证结果。只要分段结果是二进制的

使用Flask部署机器学习模型

允我心安 提交于 2021-01-15 06:20:54
Introduction A lot of Machine Learning (ML) projects, amateur and professional, start with an aplomb. The early excitement with working on the dataset, answering the obvious & not so obvious questions & presenting the results are what everyone of us works for. There are compliments thrown around and talks about going to the next step -- that's when the question arises, How? The usual suspects are making dashboards and providing insights. But mostly, the real use of your Machine Learning model lies in being at the heart of a product -- that maybe a small component of an automated mailer system

【机器学习】正则化的线性回归 —— 岭回归与Lasso回归

南笙酒味 提交于 2021-01-08 07:52:18
注 :正则化是用来防止过拟合的方法。在最开始学习机器学习的课程时,只是觉得这个方法就像某种魔法一样非常神奇的改变了模型的参数。但是一直也无法对其基本原理有一个透彻、直观的理解。直到最近再次接触到这个概念,经过一番苦思冥想后终于有了我自己的理解。 0. 正则化(Regularization ) 前面使用多项式回归,如果多项式最高次项比较大,模型就容易出现过拟合。正则化是一种常见的防止过拟合的方法,一般原理是在代价函数后面加上一个对参数的约束项,这个约束项被叫做 正则化项 (regularizer)。在线性回归模型中,通常有两种不同的正则化项: 加上所有参数(不包括$\theta_0$)的绝对值之和,即$l1$范数,此时叫做Lasso回归; 加上所有参数(不包括$\theta_0$)的平方和,即$l2$范数,此时叫做岭回归. 看过不少关于正则化原理的解释,但是都没有获得一个比较直观的理解。下面用代价函数的图像以及正则化项的图像来帮助解释正则化之所以起作用的原因。 0.1 代价函数的图像 为了可视化,选择直线方程进行优化。假设一个直线方程以及代价函数如下: $\hat{h}_{\theta} = \theta_0 + \theta_1 x$,该方程只有一个特征$x$,两个参数$\theta_0$和$\theta_1$ $J(\theta) = \frac{1}{m} \sum_{i=1}