机器学习 学习笔记

Machine Learning, Go!
(现计划暂停,将其作为工具而不是爱好去学习)

Introduction

本来第一次尝试写了一点介绍的,现在好像没啥可以介绍了,主要参考文章和课程链接去引用看就行。

开始前稍微看点python用法就行,其他的库可以现用现查,下面为原文。

第二次尝试

上次学习李宏毅老师的课程到第一个HW就卡住了,代码自己不熟悉不会用也比较麻烦。所以想在学习前把代码熟悉熟悉,尤其是Python中几个常用的库,因为我去Coursera上报名了吴老师新课奖学金,那我还是先跟着吴老师学习原理,如果遇到MATLAB就随用随学,现在Python可以先学。等奖学金申下来就可以跟着听课了,如果第一周跟课还不错,就可以申请第二个专项课程的奖学金。(每次申请只能申请一个专项课程)

大一下学期的期末复习也给我了一个教训,多用(刷题)才能理解更深入。今天是2022.7.7,后面就把离散数学和Matlab安排上日程吧!

助学金申请

准备开始啦!吴老师的新课使用Python语言,很不错嘿嘿(旧课是用Octave语言的)2020.7.21

顺便把后面的课也申请了哈哈

C1-WEEK1 Supervised/Unsupervised ML

Simply Intro

Supervised Learning

BEING GIVEN label是人给的

Regression

predict a number infinitely many possible outputs

Classification

if we have more inputs to find one output

find the boundary to calssify benign and malignant

Unsupervised Learning

Clustering

group similar data points together

谷歌通过关键词寻找相关新闻,然后放在一个组里

由于并没有人“告诉”谷歌今天新闻的关键词是什么,而是靠clustering算法自己找出关键词并分好组,我们才能说这是“无监督”的

Anomaly Detection

find unusual data points

Dimensionality reduction

Compress data using fewer numbers.

Linear Regression with One Variable

Model

some terminologies

Cost Function

这个只是其中一种,叫做Squared error cost fuction,还可以有很多其他的。

Here, cost is a measure how well our model is predicting the target price of the house.

Intuition Sense

Some Visualizations

Gradient Decent

梯度下降背后的思想是:开始时我们随机选择一个参数的组合(θ0,θ1,......,θn)\left( {\theta_{0}},{\theta_{1}},......,{\theta_{n}} \right),计算代价函数,然后我们寻找下一个能让代价函数值下降最多的参数组合。我们持续这么做直到找到一个局部最小值(local minimum),因为我们并没有尝试完所有的参数组合,所以不能确定我们得到的局部最小值是否便是全局最小值(global minimum),选择不同的初始参数组合,可能会找到不同的局部最小值。

α: The learning rate controls how big of a step you take when updating the model’s parameters, w and b

别放个假忘记怎么求偏导了哈哈哈哈,怕你忘了咱们来看下过程。之前的Cost Fuction为什么用1/2m的理由就在这,在求完偏导之后整个式子看起来更整洁。(这个求的就是梯度)

Batch

WEEK2 Regression with Multiple Input Variables

Miltiple Linear Regression

x类型变多了,我们可以用向量来表示

Vectorization

将数据向量化之后可以直接用NumPy里的dot()函数来点乘两个向量。

不仅代码量少,而且速度快:

The reason that the vectorized implementation is much faster is behind the scenes. The NumPy dot function is able to use parallel hardware in your computer and this is true whether you’re running this on a normal computer, that is on a normal computer CPU or if you are using a GPU, a graphics processor unit, that’s often used to accelerate machine learning jobs. The ability of the NumPy dot function to use parallel hardware makes it much more efficient than the for loop or the sequential calculation that we saw previously.

Feature Scaling

0-1

Mean Normalization

Z-score Normalization

Feature Engineering

像图片中,通过frontage和width的乘积创建了新的feature,同样可以引入到函数中,以提升预测的精度。

Polynomial Regression

多项式回归。线性回归并不适用于所有数据,有时我们需要曲线来适应我们的数据,比如一个二次方模型:

hθ(x)=θ0+θ1x1+θ2x22h_{\theta}\left( x \right)={\theta_{0}}+{\theta_{1}}{x_{1}}+{\theta_{2}}{x_{2}^2}

或者三次方模型:

hθ(x)=θ0+θ1x1+θ2x22+θ3x33h_{\theta}\left( x \right)={\theta_{0}}+{\theta_{1}}{x_{1}}+{\theta_{2}}{x_{2}^2}+{\theta_{3}}{x_{3}^3}

WEEK3 Classification

Classification with Logistic Regression

Logistic Regression

Decision boundary

Non-linear decision boundaries

Cost function for logistic regression

前面学习的Squared error cost function 在逻辑回归里面并不适用,会出现很多的局部极小值local minima,同时函数J并非一个convex,如下图所示

那么我们用这种

Definition Note: In this course, these definitions are used:
Loss is a measure of the difference of a single example to its target value while the
Cost is a measure of the losses over the training set

Simplified Cost Function for Logistic Regression

Gradient Descent

思路跟之前一模一样,只是现在的f(x)变了,所以其实是有本质区别的。

Overfitting

就以多项式理解。xx的次数越高,拟合的越好,但相应的预测的能力就可能变差。

问题是,如果我们发现了过拟合问题,应该如何处理?

  • 用更多的数据来跑(当然一般没有那么多数据)

  • 丢弃一些不能帮助我们正确预测的特征。可以是手工选择保留哪些特征,或者使用一些模型选择的算法来帮忙(例如PCA

  • 正则化Regularization。 保留所有的特征,但是减少参数的大小(magnitude)。

Regularization

λ很大时,就容易under fit ,所以要找到一个合适大小的λ

第一章完结撒花!2022.8.15 注意还有scikit的内容没看,这块我留了两个lab

C2-WEEK4 Neural Networks

Demand Prediction

每一层的神经元都可以获取前一层的所有数据。

中间那一层被称之为”hidden layer“ 是因为在训练时,并不会告诉你算出来的affordability是多少,而是直接给出最后的输出结果。

神经网络的结构需要自己设计。

Example: Recognizing Images

可以简单理解,每一个小的神经元在检测图片的一部分,最前面的层可能在寻找比较短的线段或者边缘,接下来他们把这些线段或者边缘组合起来,去寻找是否含有人脸的一部分,比如上图第二层中发现了眼睛鼻子和耳朵。然后接着聚合,去检测是否存在更大更粗糙的人脸,最后根据检测不同人脸的对应程度,创建一组特征,从而识别人物身份。

Neural network layer

can it be more complex?

g在这里是activation function ,它不仅仅可以是之前学的sigmoid function, 后面还会学别的

一个简单的上手实例可以看下这个基本分类:对服装图像进行分类  |  TensorFlow Core (google.cn)

引用

[1]fengdu78/Coursera-ML-AndrewNg-Notes: 吴恩达老师的机器学习课程个人笔记

[2]机器学习专项课程 | Coursera

[3]Python基础 - 飞桨AI Studio - 人工智能学习实训社区 (baidu.com) 这个上手很快

[4]吴恩达的机器学习课程笔记 | 小天爷的博客 (henryavery.cn)

[5]TensorFlow Core Tutorial | Google 官方教程 感觉对新手不是很友好

[6]Keras 中文文档 (keras-zh.readthedocs.io)

补充

ps:第一次尝试(思路并不是很正确)

第一次尝试囫囵吞枣,没找到门道,所以搁置了,下面是当时引用的一些东西

这位大佬挑战7天学完机器学习,不仅学完了,似乎还拿到了奖学金,真的很厉害,不是我也盲目跟风。
只是我好像真的时间不太够了,而且也想挑战一下自己,试试吧!!

资料链接 Linux(现查现用)
CUDA
机器学习,bilibili,Google速成教程 整体框架

openMP,MPI B站UP手推原理—自然卷小蛮 transformer spark,bert FORTRAN(目前没那么重要) 预备知识 :微积分、线性代数、概率论

这里本来插入了一个pdf,但是那个插件对双端支持性较差,就取消掉了,可以直接下载pdf查看笔记,后面估计就删除了,毕竟也没学多少(摆烂。

数据分析

课程类型 课程性质 课程名 课程资料
必修 Python基础 聪明办法学Python 文字教程:https://github.com/datawhalechina/learn-python-the-smart-way
视频教程:https://www.bilibili.com/video/BV1hv411n7Yg
SQL基础 奇妙的SQL 文字教程:https://github.com/datawhalechina/wonderful-sql
Excel基础 自由Excel 文字教程:https://github.com/datawhalechina/free-excel
视频教程:https://www.bilibili.com/video/BV1r64y1h75T
Pandas基础 Pandas数据处理与分析 文字教程:https://github.com/datawhalechina/joyful-pandas
配套教材:《Pandas入门与实践:Python数据处理与分析》 耿远昊. 人民邮电出版社
Numpy基础 巨硬的NumPy 文字教程:https://github.com/datawhalechina/powerful-numpy
视频教程:https://www.bilibili.com/video/BV1Ym4y1U7at
机器学习理论 吃瓜教程 文字教程:https://github.com/datawhalechina/pumpkin-book
视频教程:https://www.bilibili.com/video/BV1Mh411e7VU
配套教材:《机器学习公式详解》 谢文睿,秦州. 人民邮电出版社
机器学习实践 西瓜书代码实战 文字教程:https://github.com/datawhalechina/machine-learning-toy-code
视频教程:https://www.bilibili.com/video/BV1w64y1x7Pi
数据分析理论&实践 动手学数据分析 文字教程:https://github.com/datawhalechina/hands-on-data-analysis
选修 集成学习理论&实践 集成学习 文字教程:https://github.com/datawhalechina/ensemble-learning
视频教程:https://www.bilibili.com/video/BV1R54y137Q5
数据可视化 matplotlib奇遇记 文字教程:https://github.com/datawhalechina/fantastic-matplotlib
极好的Plotly 文字教程:https://github.com/datawhalechina/wow-plotly
视频教程:https://www.bilibili.com/video/BV1Df4y1A7aR
机器学习理论原理 钥匙书 文字教程:https://github.com/datawhalechina/key-book
实践 分类 零基础入门金融风控-贷款违约预测 赛题介绍:根据贷款申请人的数据信息预测其是否有违约的可能
教程地址:https://github.com/datawhalechina/team-learning-data-mining/tree/master/FinancialRiskControl
零基础入门数据挖掘-心跳信号分类预测 赛题介绍:根据心电图感应数据预测心跳信号
教程地址:https://github.com/datawhalechina/team-learning-data-mining/tree/master/HeartbeatClassification
回归 零基础入门数据挖掘之二手车交易价格预测 赛题介绍:根据汽车类型等信息预测二手汽车的交易价格
教程地址:https://github.com/datawhalechina/team-learning-data-mining/tree/master/SecondHandCarPriceForecast
综合 零基础入门数据分析之学术前沿趋势分析 赛题介绍:使用公开的arXiv论文完成对应的数据分析操作
教程地址:https://github.com/datawhalechina/team-learning-data-mining/tree/master/AcademicTrends
数据竞赛Baseline & Topline分享 教程地址:https://github.com/datawhalechina/competition-baseline

推荐系统<补充

课程性质 课程名称 课程资料
深度学习理论 水很深的深度学习 文字教程:https://github.com/datawhalechina/unusual-deep-learning
视频教程:https://www.bilibili.com/video/BV1iq4y197L4
李宏毅机器学习笔记 文字教程:https://github.com/datawhalechina/leeml-notes
视频教程:https://www.bilibili.com/video/BV1JA411c7VT
深度学习实践 深入浅出PyTorch 文字教程:https://github.com/datawhalechina/thorough-pytorch
视频教程:https://www.bilibili.com/video/BV1e341127Lt
推荐系统理论&实践 有趣的推荐算法 文字教程:https://github.com/datawhalechina/fun-rec
强化学习理论&实践 强化学习教程 文字教程:https://github.com/datawhalechina/easy-rl
配套教材:《Easy RL:强化学习教程》 王琦,杨毅远,江季. 人民邮电出版社

CV

课程性质 课程名称 课程资料
计算机视觉理论&实践 OpenCV 文字教程:https://github.com/datawhalechina/magic-cv
动手学CV 文字教程:https://github.com/datawhalechina/dive-into-cv-pytorch
语义分割 零基础入门语义分割-地表建筑物识别 赛题介绍:使用给定的航拍图像训练模型并完成地表建筑物识别
教程地址:https://github.com/datawhalechina/team-learning-cv/tree/master/AerialImageSegmentation
OCR 零基础入门CV - 街景字符编码识别 赛题介绍:从Google街景图像中识别出门牌号
教程地址:https://github.com/datawhalechina/team-learning-cv/tree/master/CharacterCodingRecognition

NLP

课程性质 课程名称 课程资料
transformers库实践 基于transformers的自然语言处理(NLP)入门 文字教程:https://github.com/datawhalechina/learn-nlp-with-transformers
文本分类 零基础入门NLP - 新闻文本分类 赛题介绍:对新闻文本进行分类
教程地址:https://github.com/datawhalechina/team-learning-nlp/tree/master/NewsTextClassification