diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..cc67606f --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,4 @@ +{ + "python.linting.pylintEnabled": true, + "python.linting.enabled": true +} \ No newline at end of file diff --git a/Python/scipy/14cluster.md b/Python/scipy/14cluster.md index e69de29b..375196ed 100644 --- a/Python/scipy/14cluster.md +++ b/Python/scipy/14cluster.md @@ -0,0 +1,130 @@ +# 聚类 +## cluster.vq +Provides routines for k-means clustering, generating code books from k-means models and quantizing vectors by comparing them with centroids in a code book. + +function | introduction +----|---- +whiten(obs[, check_finite]) | Normalize a group of observations on a per feature basis.每行元素除以该行的标准差。 +vq(obs, code_book[, check_finite]) | Assign codes from a code book to observations. +kmeans(obs, k_or_guess[, iter, thresh, …]) | Performs k-means on a set of observation vectors forming k clusters. +kmeans2(data, k[, iter, thresh, minit, …]) | Classify a set of observations into k clusters using the k-means algorithm. + +## cluster.hierarchy + +Hierarchical clustering (scipy.cluster.hierarchy) + +* These functions cut hierarchical clusterings into flat clusterings or find the roots of the forest formed by a cut by providing the flat cluster ids of each observation. + +functions | introduction +----|---- +fcluster(Z, t[, criterion, depth, R, monocrit]) | Form flat clusters from the hierarchical clustering defined by the given linkage matrix. +fclusterdata(X, t[, criterion, metric, …]) | Cluster observation data using a given metric. +leaders(Z, T) | Return the root nodes in a hierarchical clustering. + +* These are routines for agglomerative clustering. + +functions | introduction +----|---- +linkage(y[, method, metric, optimal_ordering]) | Perform hierarchical/agglomerative clustering. +single(y) | Perform single/min/nearest linkage on the condensed distance matrix y. +complete(y) | Perform complete/max/farthest point linkage on a condensed distance matrix. +average(y) | Perform average/UPGMA linkage on a condensed distance matrix. +weighted(y) | Perform weighted/WPGMA linkage on the condensed distance matrix. +centroid(y) | Perform centroid/UPGMC linkage. +median(y) | Perform median/WPGMC linkage. +ward(y) | Perform Ward’s linkage on a condensed distance matrix. + +* These routines compute statistics on hierarchies. + + +functions | introduction +----|---- +cophenet(Z[, Y]) | Calculate the cophenetic distances between each observation in the hierarchical clustering defined by the linkage Z. +from_mlab_linkage(Z) | Convert a linkage matrix generated by MATLAB(TM) to a new linkage matrix compatible with this module. +inconsistent(Z[, d]) | Calculate inconsistency statistics on a linkage matrix. +maxinconsts(Z, R) | Return the maximum inconsistency coefficient for each non-singleton cluster and its children. +maxdists(Z) | Return the maximum distance between any non-singleton cluster. +maxRstat(Z, R, i) | Return the maximum statistic for each non-singleton cluster and its children. + +to_mlab_linkage(Z) | Convert a linkage matrix to a MATLAB(TM) compatible one. + +* Routines for visualizing flat clusters. + +functions | introduction +----|---- +dendrogram(Z[, p, truncate_mode, …]) | Plot the hierarchical clustering as a dendrogram. + +* These are data structures and routines for representing hierarchies as tree objects. + +functions | introduction +----|---- +ClusterNode(id[, left, right, dist, count]) | A tree node class for representing a cluster. +leaves_list(Z) | Return a list of leaf node ids. +to_tree(Z[, rd]) | Convert a linkage matrix into an easy-to-use tree object. +cut_tree(Z[, n_clusters, height]) | Given a linkage matrix Z, return the cut tree. +optimal_leaf_ordering(Z, y[, metric]) | Given a linkage matrix Z and distance, reorder the cut tree. + +* These are predicates for checking the validity of linkage and inconsistency matrices as well as for checking isomorphism of two flat cluster assignments. + +functions | introduction +----|---- +is_valid_im(R[, warning, throw, name]) | Return True if the inconsistency matrix passed is valid. +is_valid_linkage(Z[, warning, throw, name]) | Check the validity of a linkage matrix. +is_isomorphic(T1, T2) | Determine if two different cluster assignments are equivalent. +is_monotonic(Z) | Return True if the linkage passed is monotonic. +correspond(Z, Y) | Check for correspondence between linkage and condensed distance matrices. +num_obs_linkage(Z) | Return the number of original observations of the linkage matrix passed. + +* Utility routines for plotting: + + +functions | introduction +----|---- +set_link_color_palette(palette) | Set list of matplotlib color codes for use by dendrogram. + +## 原理 + +K均值聚类是一种在一组未标记数据中查找聚类和聚类中心的方法。 直觉上,我们可以将一个群集(簇聚)看作 - 包含一组数据点,其点间距离与群集外点的距离相比较小。 给定一个K中心的初始集合,K均值算法重复以下两个步骤 - + +* 对于每个中心,比其他中心更接近它的训练点的子集(其聚类)被识别出来。 +* 计算每个聚类中数据点的每个要素的平均值,并且此平均向量将成为该聚类的新中心。 + + +重复这两个步骤,直到中心不再移动或分配不再改变。 然后,可以将新点x分配给最接近的原型的群集。 SciPy库通过集群包提供了K-Means算法的良好实现。 下面来了解如何使用它。 + +## 实现 + +* 导入K-Means +```py +from SciPy.cluster.vq import kmeans,vq,whiten +Python +``` +* 数据生成 +```py +from numpy import vstack,array +from numpy.random import rand + +# data generation with three features +data = vstack((rand(100,3) + array([.5,.5,.5]),rand(100,3))) +``` +* 根据每个要素标准化一组观察值。 在运行K-Means之前,使用白化重新缩放观察集的每个特征维度是有好处的。 每个特征除以所有观测值的标准偏差以给出其单位差异。美化数据 +```py +# whitening of data +data = whiten(data) +print (data) +``` +* 用三个集群计算K均值现在使用以下代码计算三个群集的K均值。 +```py +# computing K-Means with K = 3 (2 clusters) +centroids,_ = kmeans(data,3) +``` +* 上述代码对形成K个簇的一组观测向量执行K均值。 K-Means算法调整质心直到不能获得足够的进展,即失真的变化,因为最后一次迭代小于某个阈值。 在这里,可以通过使用下面给出的代码打印centroids变量来观察簇。 +```py +print(centroids) +``` +* 使用下面给出的代码将每个值分配给一个集群。 +```py +# assign each sample to a cluster +clx,_ = vq(data,centroids) +``` +* vq函数将'M'中的每个观察向量与'N' obs数组与centroids进行比较,并将观察值分配给最近的聚类。 它返回每个观察和失真的聚类。 我们也可以检查失真。使用下面的代码检查每个观察的聚类。 \ No newline at end of file diff --git a/Python/scipy/18constant.md b/Python/scipy/18constant.md new file mode 100644 index 00000000..b45b63e1 --- /dev/null +++ b/Python/scipy/18constant.md @@ -0,0 +1,4 @@ +## 数字常量 + +## 物理常量 + diff --git a/Python/scipy/1basicfunction.md b/Python/scipy/1basicfunction.md deleted file mode 100644 index b95ffe4f..00000000 --- a/Python/scipy/1basicfunction.md +++ /dev/null @@ -1,10 +0,0 @@ -## index trics - -## shape manipulation - -## polynomials - -## vectorizing functions - -## type handling - diff --git a/Python/scipy/0introduction.md b/Python/scipy/1introduction.md similarity index 100% rename from Python/scipy/0introduction.md rename to Python/scipy/1introduction.md diff --git a/Python/scipy/2special.md b/Python/scipy/2special.md index 25550bb9..d1eac5e4 100644 --- a/Python/scipy/2special.md +++ b/Python/scipy/2special.md @@ -3,4 +3,32 @@ ## Bessel functions of real order > bassel函数 -## Cython Bindings for Special Functions \ No newline at end of file +$$ +x^2\frac{d^2y}{dx^2}+x\frac{dy}{dx}+(x^2-\alpha^2)y=0 +$$ +```py +from scipy import special +def drumhead_height(n, k, distance, angle, t): + kth_zero = special.jn_zeros(n, k)[-1] + return np.cos(t) * np.cos(n*angle) * special.jn(n, distance*kth_zero) +theta = np.r_[0:2*np.pi:50j] +radius = np.r_[0:1:50j] +x = np.array([r * np.cos(theta) for r in radius]) +y = np.array([r * np.sin(theta) for r in radius]) +z = np.array([drumhead_height(1, 1, r, theta, 0.5) for r in radius]) + +import matplotlib.pyplot as plt +from mpl_toolkits.mplot3d import Axes3D +from matplotlib import cm +fig = plt.figure() +ax = Axes3D(fig) +ax.plot_surface(x, y, z, rstride=1, cstride=1, cmap='RdBu_r', vmin=-0.5, vmax=0.5) +ax.set_xlabel('X') +ax.set_ylabel('Y') +ax.set_zlabel('Z') +plt.show() +``` + +## Cython Bindings for Special Functions +> scipy.special.cython_special + diff --git a/Python/scipy/8linalg.md b/Python/scipy/8linalg.md index cc218617..d2aacceb 100644 --- a/Python/scipy/8linalg.md +++ b/Python/scipy/8linalg.md @@ -1,13 +1,129 @@ -## 线性代数 -> 主要修改二维数组 +# 线性代数 + +## 简介 SciPy是使用优化的ATLAS LAPACK和BLAS库构建的。 它具有非常快的线性代数能力。 所有这些线性代数例程都需要一个可以转换为二维数组的对象。 这些例程的输出也是一个二维数组。 +### SciPy.linalg与NumPy.linalg + +scipy.linalg包含numpy.linalg中的所有函数。 另外,scipy.linalg还有一些不在numpy.linalg中的高级函数。 在numpy.linalg上使用scipy.linalg的另一个优点是它总是用BLAS/LAPACK支持编译,而对于NumPy,这是可选的。 因此,根据NumPy的安装方式,SciPy版本可能会更快。 ## 线性方程组 -## 行列式 +### 数学实例 +scipy.linalg.solve特征为未知的x,y值求解线性方程a * x + b * y = Z。 +作为一个例子,假设需要解下面的联立方程。 +``` +x+3y+5z=10 +2x+5y+z=8 +2x+3y+8z=3 +``` +要求解x,y,z值的上述方程式,可以使用矩阵求逆来求解向量,如下所示。 +$$ +A[x,y,z]^T=[10,8,3]^T\\ +[x,y,z]^T=A^{-1}[10,8,3]^T +$$ -## 特征值特征向量 +### 编程实现 +但是,最好使用linalg.solve命令,该命令可以更快,更稳定。求解函数采用两个输入'a'和'b',其中'a'表示系数,'b'表示相应的右侧值并返回解矩阵。 +```py +#importing the scipy and numpy packages +from scipy import linalg +import numpy as np + +#Declaring the numpy arrays +a = np.array([[3, 2, 0], [1, -1, 0], [0, 5, 1]]) +b = np.array([2, 4, -1]) + +#Passing the values to the solve function +x = linalg.solve(a, b) + +#printing the result array +print (x) +``` +执行上面示例代码,得到以下结果 +```py +[ 2. -2. 9.] +``` + + +## 行列式 + + +方阵A的行列式通常表示为| A |并且是线性代数中经常使用的量。 在SciPy中,这是使用det()函数计算的。 它将矩阵作为输入并返回一个标量值。 +```py +#importing the scipy and numpy packages +from scipy import linalg +import numpy as np + +#Declaring the numpy array +A = np.array([[1,2],[3,4]]) + +#Passing the values to the det function +x = linalg.det(A) + +#printing the result +print (x) + +# 执行上面示例代码,得到以下结果 - +-2.0 +``` + +## 特征值和特征向量特征值 + +特征向量问题是最常用的线性代数运算之一。 我们可以通过考虑以下关系式来找到方阵(A)的特征值(λ)和相应的特征向量(v) +``` +Av = λv +``` +scipy.linalg.eig从普通或广义特征值问题计算特征值。 该函数返回特征值和特征向量。 +```py +#importing the scipy and numpy packages +from scipy import linalg +import numpy as np + +#Declaring the numpy array +A = np.array([[1,2],[3,4]]) + +#Passing the values to the eig function +l, v = linalg.eig(A) + +#printing the result for eigen values +print (l) + +#printing the result for eigen vectors +print (v) +``` +执行上面示例代码,得到以下结果 - +``` +[-0.37228132+0.j 5.37228132+0.j] +[[-0.82456484 -0.41597356] + [ 0.56576746 -0.90937671]] +``` + +## 奇异值分解奇异值分解(SVD) + +可以被认为是特征值问题扩展到非矩阵的矩阵。 +scipy.linalg.svd将矩阵'a'分解为两个酉矩阵'U'和'Vh',以及一个奇异值(实数,非负)的一维数组's',使得a == U * S * Vh,其中'S'是具有主对角线's'的适当形状的零点矩阵。 + +```py +#importing the scipy and numpy packages +from scipy import linalg +import numpy as np + +#Declaring the numpy array +a = np.random.randn(3, 2) + 1.j*np.random.randn(3, 2) + +#Passing the values to the eig function +U, s, Vh = linalg.svd(a) + +# printing the result +print (U, Vh, s) + +# 执行上面示例代码,得到以下结果 - +[[-0.60142679+0.28212127j 0.35719830-0.03260559j 0.61548126-0.22632383j] + [-0.00477296+0.44250532j 0.64058557+0.15734719j -0.40414313+0.45357092j] + [ 0.46360086+0.38462177j -0.18611686+0.6337182j 0.44311251+0.06747886j]] [[ 0.98724353+0.j -0.01113675+0.15882756j] + [-0.15921753+0.j -0.06905445+0.9848255j ]] [ 2.04228408 1.33798044] + + ``` -## 奇异值分解 diff --git a/Python/scipy/README.md b/Python/scipy/README.md index 7dec8fda..8f32fdf3 100644 --- a/Python/scipy/README.md +++ b/Python/scipy/README.md @@ -1,3 +1,5 @@ # 说明 -别纠结了,这一部分,就直接参考官方的教程跟api文档就好了,不用学习。你需要学的是数学。然后每次遇到数学问题,查手册解决。 \ No newline at end of file +别纠结了,这一部分,就直接参考官方的教程跟api文档就好了,不用学习。你需要学的是数学。然后每次遇到数学问题,查手册解决。 + +别写了,查看文档就好。浪费时间 diff --git a/Python/scipy/bessel_test.py b/Python/scipy/bessel_test.py new file mode 100644 index 00000000..0286b4dc --- /dev/null +++ b/Python/scipy/bessel_test.py @@ -0,0 +1,21 @@ +from scipy import special +import numpy as np +def drumhead_height(n, k, distance, angle, t): + kth_zero = special.jn_zeros(n, k)[-1] + return np.cos(t) * np.cos(n*angle) * special.jn(n, distance*kth_zero) +theta = np.r_[0:2*np.pi:50j] +radius = np.r_[0:1:50j] +x = np.array([r * np.cos(theta) for r in radius]) +y = np.array([r * np.sin(theta) for r in radius]) +z = np.array([drumhead_height(1, 1, r, theta, 0.5) for r in radius]) + +import matplotlib.pyplot as plt +from mpl_toolkits.mplot3d import Axes3D +from matplotlib import cm +fig = plt.figure() +ax = Axes3D(fig) +ax.plot_surface(x, y, z, rstride=1, cstride=1, cmap='RdBu_r', vmin=-0.5, vmax=0.5) +ax.set_xlabel('X') +ax.set_ylabel('Y') +ax.set_zlabel('Z') +plt.show() \ No newline at end of file diff --git a/Python/scipy/cluster_test.py b/Python/scipy/cluster_test.py new file mode 100644 index 00000000..47f43677 --- /dev/null +++ b/Python/scipy/cluster_test.py @@ -0,0 +1,12 @@ +import numpy as np +from scipy.cluster.vq import kmeans,vq,whiten + +data = np.vstack((np.random.rand(100,3)+np.array([.5,.5,.5]),np.random.rand(100,3))) +data = whiten(data) + +cent,_ = kmeans(data,3) + +print(cent) + +# assign each sample to a cluster +clx,_ = vq(data,centroids) diff --git a/Python/scipy/linalg_test.py b/Python/scipy/linalg_test.py new file mode 100644 index 00000000..23f1bc45 --- /dev/null +++ b/Python/scipy/linalg_test.py @@ -0,0 +1,37 @@ +from scipy import linalg +import numpy as np + +#Declaring the numpy arrays +a = np.array([[3, 2, 0], [1, -1, 0], [0, 5, 1]]) +b = np.array([2, 4, -1]) + +# 求矩阵的行列式 +print(np.linalg.det(a)) +print(linalg.det(a)) + +# 求矩阵的特征值和特征向量 + +print('eig:') +print(np.linalg.eig(a)) +print(linalg.eig(a)) + +# 奇异值分解svd +print('svd:') +m = np.array([[3,2,4],[1,3,2]]) +print(np.linalg.svd(a)) +print(linalg.svd(a)) + +# 利用矩阵的逆求解方程组 +a_ = np.linalg.inv(a) +x = np.matmul(a_,b) +print(x) + +# 使用numpy的线性代数部分求解矩阵的逆 +x = np.linalg.solve(a,b) +print(x) + +#Passing the values to the solve function +x = linalg.solve(a, b) + +#printing the result array +print(x) \ No newline at end of file diff --git a/工作日志/2020年10月1日.md b/工作日志/2020年10月1日.md index 0bf2ffcd..4e167038 100644 --- a/工作日志/2020年10月1日.md +++ b/工作日志/2020年10月1日.md @@ -2,6 +2,55 @@ * 使用python3编程,实现markdown文章存放到本地。自己写Python对markdown语法的解析程序把。 +# 国庆节安排 + +10.1 + +上午 完成3-4 +下午 完成5-6 +晚上 完成7-8 +10.2 +上午-下午:写界面、去聚餐 + +晚上 完成9-10 + +10.3 +上午-下午:写界面、去聚餐 +晚上 完成11-12 + +10.4 +上午 完成13-14 +下午 完成15-16 +晚上 完成27-29 + +----------------- +10.5 机器学习基石上完成 + +10.6 机器学习基石下的一半 + +10.7 机器学习基石下的一半 + +10.8 机器学习基石完成 + +> 整理好相关的机器学习笔记。进行附上代码的实现。 +-------------------- + +10.9-10.11 统计学习方法 + +10.11-10.20 机器学习西瓜书 + +10.20-10.25 机器学习实战,编程。sklearn + +10.25-10.30 TensorFlow教程学会 + +11.01-11.10 神经网络的五套课程(仅仅学习三套就够了,因为后边的是针对专门的领域的) + +11.10-11.20 联邦学习 + +----------------------------------- + +基础知识->算法实现->科研论文->系统实现 + diff --git a/工作日志/2020年9月29日.md b/工作日志/2020年9月29日.md index d8fc65ef..75eb9200 100644 --- a/工作日志/2020年9月29日.md +++ b/工作日志/2020年9月29日.md @@ -1,12 +1,13 @@ # 组会的PPT结构 +> 直接搜集资料开始做ppt吧 ## 情报利用的现状 ## 联邦学习的现状 -## 机器学习在情报利用领域可能的应用路径 +## 联邦学习的过程 -## 拟打算应用的机器学习算法 +## 机器学习在情报利用领域可能的应用路径以及拟打算应用的机器学习算法 ## 面临的难题 diff --git a/工作日志/2020年9月3日.md b/工作日志/2020年9月3日.md index b02bdb6d..84f9ad3a 100644 --- a/工作日志/2020年9月3日.md +++ b/工作日志/2020年9月3日.md @@ -1,14 +1,14 @@ # 情报威胁与联邦学习 ## 研究方向 -* 情报威胁----定义系统的应用场景,包括输入输出。 +* 威胁情报----定义系统的应用场景,包括输入输出。(情报生成和情报利用两条思路) * 联邦学习----定义系统的算法,包括各种处理细节。 ------------------------- ## 总体规划 * 第一阶段:通过情报威胁相关论文和资料,定义应用场景(由蒋师兄完成) -* 第二阶段:学习统计学、机器学习和联邦学习的基础知识、论文和资料 +* 第二阶段:学习统计学、机器学习和联邦学习的基础知识;阅读论文和资料了解前沿的发展。 * 第三阶段:复现联邦学习论文,搭建联邦学习的框架,实现机器学习过程。 * 第四阶段:对联邦学习框架的细节进行研究,改善应用场景下的联邦学习过程。例如:提升安全性;增强分布式计算能力等。 diff --git a/工作日志/2020年9月6日.md b/工作日志/2020年9月6日.md index 38167e10..cf7a5a4e 100644 --- a/工作日志/2020年9月6日.md +++ b/工作日志/2020年9月6日.md @@ -26,7 +26,7 @@ python3-numpy-scipy-matplotlib-pandas√ 1. 《机器学习》吴恩达的课程一看。跟着做做笔记。 * 完成第一轮,笔记对照(看一部分,总结一部分。) -2. 《机器学习基石》上&下 +2. 《机器学习基石》上&下//李宏毅的机器学习也行 * 完成第二轮,笔记对照(跟上实践) 3. 《统计学习方法》一看。3Blue1Brown的视频看一看。跟着做做笔记。 4. 《机器学习西瓜书》一看。跟着做做笔记。 diff --git a/工作日志/会议记录.md b/工作日志/会议记录.md new file mode 100644 index 00000000..2ea2ff6f --- /dev/null +++ b/工作日志/会议记录.md @@ -0,0 +1,91 @@ +# 蒋 + +### 答辩内容 +* 威胁情报的定义 +* 威胁情报的分类层次。 +* 恶意样本的IOC情报描述。 +* IOC共享框架,泄露隐私的日志数据。保证情报共享,又能不泄露隐私。 +* 联邦学习的应用 +* 联邦学习的分类 + +### 现存的问题 +* 恶意样本的数据,打标签问题。 +* 梯度的隐私计算和聚合问题。 +* 多分布客户端的梯度的收敛和效率问题。 +* 梯度共享和激励问题 +* 梯度聚合的鲁棒性 + +### 问答 +* 夏:梯度的安全计算是针对情报领域的吗?威胁情报的梯度共享,具有什么样的特点。 +* 夏:给出形式化定义。经过调研,说明研究IOC的原因。 +* 夏:对金融领域和医学领域的例子吃透。 +* 夏:现有的威胁情报已经存在。然后利用威胁情报。实现现有的威胁情报的共享与利用。而不是生成威胁情报。 +* 蒋:威胁情报如果不存在隐私?生成威胁情报的数据存在隐私?夏:关键是威胁情报的利用。研究清楚。 +* 夏:论证采用的方案,是目前所有的方案中,最有效的方案。需要给出金融领域的某个案例的详细解释。 +* 夏:组织大家看论文,进行讨论。 +* 夏:将人的工作,转换成可以用计算机计算工作。 +* 夏:现在的规则共享方案?共享过程中存在的问题?把人的工作量转换为计算机的工作量?输入与输出搞清楚,黑盒是什么? +* 夏:研究必须有阶段性成果。跟上当前最新的研究。不能过时啊。 + + +## 李春燕 + +### 主要内容:区块链和边缘计算 + +* 区块链边缘计算进行整合的动机。异构性、低时延、安全和隐私性。 +* 边缘计算的框架。云层-小型边缘计算基站-边缘设备 +* 研究现状-网络、存储、计算 + * 边缘计算的网络:数据通信和区块链通信进行结合。基于区块链的软件定义网络的边缘计算架构。 + * 边缘计算的存储:区块链外的数据存储,进行hash索引。可扩展的区块链数据库。 + * 边缘计算的计算:对计算资源进行调度。公平性与激励机制。 + +### 问答 + +* 夏:边缘计算与情报的关系。 +* 夏:边缘计算、移动计算、雾计算的关系与区别。以及边缘计算与区块链的关系 +* 李:本地数据与服务器数据进行通信,会存在数据完整性的问题。解决三个方面的问题:计算,算力与资源调度。存储,网络。 +* 夏:目前存在的具体问题。问题的定义,目标的定义。目前的解决方案,核心需要解决的问题,存在的问题,自己要解决的问题。 + +## 李文超 + +### 主要内容:联邦学习的梯度保护 +* 存在的问题:共享参数,对模型进行推理。 +* 方法:安全多方计算、差分隐私、同态加密。 +* 给出了具体的实现算法:加密解密。加权隐私,加密聚合。 +* 改进的方法:代理重加密进行数据访问授权访问方法。基于聚合方法可搜索加密技术分类。 + + +### 问答 +* 蒋:对联邦学习改进方案,非常可以。但是与应用场景的定义还没有结合。 +* 夏:支撑性工作,与蒋师兄的思路进行结合。基础知识普及。 +* 夏:梯度的隐私计算与一般的隐私计算的不同?当前的解决情况,梯度隐私保护存在的问题。通信保密和存储保密。 +* 夏:补信息论、控制论、形式语言自动化?。相关概念 + + + + +## 殷康龙 + +### 主要内容 + +* 有意义的数据是信息,25是数据不是信息,蒋昌南今年25,有意义了是信息,经过理解的是知识。 +要具体深入,要人家听明白。 +* IOC的自动利用过程。 + +* 一个是现在已有的情报共享系统工具熟悉,了解所有人的工具,聚合在系统中实现,openIOC,重点任务是怎么做系统。 +* 出门还是需要请假。工作日记上报。 + +### 论文阅读 +* 需要了解更多具体实现方案。 +* 对相关领域的调研太少了。不能只是学习基础知识了。看论文也很关键。 +* 领域调研!!!!!!!!!!!! +* 对情报利用领域的调研太少了。 +* 还是需要自己的对相关领域的研究和工作。 +* 对场景相关的概念定义啊:情报啊,IOC等等,相关领域的所有概念。 + +### 威胁情报 +* 还需要对威胁情报进行更加详细的定义。 + +### 例子 +* 医学Patient Clustering Improves Efficiency of Federated Machine Learning to Predict Mortality and Hospital Stay Time Using Distributed Electronic Medical Records +* 金融领域具体实现的例子 \ No newline at end of file diff --git a/机器学习/机器学习实战/01matplot3D图像.py b/机器学习/机器学习实战/01matplot3D图像.py index da3741dc..40d8e98e 100644 --- a/机器学习/机器学习实战/01matplot3D图像.py +++ b/机器学习/机器学习实战/01matplot3D图像.py @@ -11,6 +11,7 @@ x_2= np.arange(0,10,0.1) x_2 = np.expand_dims(x_2,1) x_2 = np.repeat(x_2,100,axis=1) +y = np.repe y = ((x_1+x_2-10)**2) print(x_1.flatten()) diff --git a/机器学习/机器学习实战/03多元线性回归.py b/机器学习/机器学习实战/03多元线性回归.py new file mode 100644 index 00000000..8c0867fe --- /dev/null +++ b/机器学习/机器学习实战/03多元线性回归.py @@ -0,0 +1,2 @@ +import numpy as np + diff --git a/机器学习/机器学习实战/04分类.py b/机器学习/机器学习实战/04分类.py new file mode 100644 index 00000000..e69de29b diff --git a/机器学习/机器学习课程笔记/机器学习基础.md b/机器学习/机器学习课程笔记/01机器学习基础.md similarity index 100% rename from 机器学习/机器学习课程笔记/机器学习基础.md rename to 机器学习/机器学习课程笔记/01机器学习基础.md diff --git a/机器学习/机器学习课程笔记/线性回归.md b/机器学习/机器学习课程笔记/02线性回归.md similarity index 100% rename from 机器学习/机器学习课程笔记/线性回归.md rename to 机器学习/机器学习课程笔记/02线性回归.md diff --git a/机器学习/机器学习课程笔记/03多元线性回归.md b/机器学习/机器学习课程笔记/03多元线性回归.md new file mode 100644 index 00000000..8afb494c --- /dev/null +++ b/机器学习/机器学习课程笔记/03多元线性回归.md @@ -0,0 +1,58 @@ +# 多元线性回归 + +## 问题 + +* 假设函数 + +$$ +h_\theta(x)=\theta_0+\theta_1x_1+\theta_2x+\theta_3x+\theta_4x\\ += [\theta_0,\theta_1,\theta_2,\theta_3,\theta_4]\times[1,x_1,x_2,x_3,x_4]^T\\ +=\overrightarrow{\theta}^T\times\overrightarrow{x} +$$ + +* 代价函数 + +$$ +J(\overrightarrow{\theta})=\frac{1}{2m}\sum_{i=1}^m(h_\theta(\overrightarrow{x}^{(i)})-y^{(i)})^2 +$$ + +* 梯度下降 + +$$ +\theta_j = \theta_j - \alpha\frac{\partial}{\partial\theta_j}J(\overrightarrow{\theta}) +$$ + +## 特征放缩(归一化处理) + +当一个假设函数的多个特征处在相同的范围的时候,函数会更快的收敛。 +* 均值归一化 +* 标准归一化 + +## 学习率 + +归一化之后的学习率在0-1之间。可以通过十倍差,寻找尝试寻找合适的学习率进行学习。 + +## 特征和多项式回归 + +梯度下降和以构建多项式项,用多项式的乘积项或者高阶项,进行梯度下降,一样可以拟合。 +$$ +y=\theta_0+\theta_1x_1^2+\theta_2x_1x_2+\theta_3x_1^2 +$$ + +## 正规方程法 + +通过准确求值的方法,得到损失函数的最小值。 + +* X表示特征矩阵 +* Y表示结果向量 +* $\theta$参数向量 + + +## 编程任务 + +* 使用梯度下降,拟合多个特征的多项式函数。 +* 对原始数据进行归一化操作 +* 选择不同的学习率观察损失函数的变换过程(收敛速度) +* 绘制梯度下降过程中,损失函数与学习率的关系 +* 使用正规方程法求解多项式的系数。两者进行比较。 + diff --git a/机器学习/机器学习课程笔记/04逻辑回归分类.md b/机器学习/机器学习课程笔记/04逻辑回归分类.md new file mode 100644 index 00000000..734261ac --- /dev/null +++ b/机器学习/机器学习课程笔记/04逻辑回归分类.md @@ -0,0 +1,67 @@ +# 分类 + +## 回归方式解决分类问题 + +* 存在奇异值会严重影响回归函数。 + + +## 逻辑回归(假的回归方法)模型 + +* 训练集 + +$$ +\{x^{(1)},y^{(1)}\},\{x^{(2)},y^{(2)}\},\dots,\{x^{(m)},y^{(m)}\} +$$ + +* 数据格式 + +$$ +x\in\begin{bmatrix} + x_0\\ + x_1\\ + \vdots\\ + x_n +\end{bmatrix} +x_0=1,y\in\{0,1\} +$$ +> m个训练集,n+1个训练参数 +* 假设函数 + +$$ +h_\theta(x)=\frac{1}{1+e^{-\theta^Tx}} +$$ + +* 代价函数 + +$$ +cost(h_\theta(x),y)=\{\begin{aligned} + -\log (h_\theta(x)) && y =1\\ + -\log (1-h_\theta(x))&& y=0 +\end{aligned} +$$ +* 压缩版代价函数 +$$ +cost(h_\theta(x),y)=-y\log (h_\theta(x))-(1-y)\log (1-h_\theta(x)) +$$ + +* 梯度下降 + + +$$ +\theta_j = \theta_j - \alpha\frac{\partial}{\partial\theta_j}J(\overrightarrow{\theta}) +$$ + +## 特征缩放与数据归一化 +> 与多元线性回归的方法一样。 + + +## 编程任务1 + +* 构造多元分类数据集 +* 对数据进行归一化处理 +* 建立梯度下降公式,进行迭代。 +* 选择不同学习率,观察梯度下降过程,并绘制。 + +## 编程任务2 + +* 使用python内置的高级优化算法(梯度下降之外的算法进行拟合,并对比不同算法的拟合效果) diff --git a/概率论与数理统计/第17节 多元线性回归.md b/概率论与数理统计/第17节 多元线性回归.md index 9e3aa4c3..d22ebbd9 100644 --- a/概率论与数理统计/第17节 多元线性回归.md +++ b/概率论与数理统计/第17节 多元线性回归.md @@ -2,7 +2,7 @@ ## 1 多元线性回归的数学描述 -### 定义:多远线性回归 +### 定义:多元线性回归 * 声明 $$ 随机变量与,p个普通变量x_1,\cdots,x_p @@ -30,9 +30,9 @@ X=\begin{bmatrix} 1&x_{n1}&\cdots&x_{np} \end{bmatrix}, \beta=\begin{bmatrix} - \beta_1\\ + \beta_0\\ \vdots\\ - \beta_n + \beta_p \end{bmatrix}, \varepsilon=\begin{bmatrix} \varepsilon_1\\ diff --git a/线性代数/3blue1brown.md b/线性代数/3blue1brown.md new file mode 100644 index 00000000..44fd76e7 --- /dev/null +++ b/线性代数/3blue1brown.md @@ -0,0 +1,32 @@ +# 线性代数的本质 +> 宇宙最强系列视频 + +## 向量的本质 + +* 图形=符号=坐标 + +## 线性组合、张成的空间与积 + +* 基向量i,j的可以表示向量空间。 +* 任意两个向量的线性组合可以表示平面,称为向量的张成空间 +* 不同的基向量,对向量空间的描述不同。 + +## 线性变换 +* 线性变换:保持平行 +* 原来的向量表示,乘以变换后的基向量表示 +* 基向量变换。矩阵表示列向量的个数,列向量的每一个值,都表示向量的一个维度。矩阵的第一个维度,是所有列向量的第一个维度的排列。源向量的每一个维度,代表不同的基向量的scaling,缩放。 +* 线性变换, + * 变换后的基向量=矩阵的列向量 + * 原向量的每一个维度,都是对基向量的缩放。 + * 目标向量的每一个维度,都是变换后的基向量在这一个维度的缩放的和。 + +![](img/线性变换.png) + +[1,2,3,4]自身是1维数组,维度是4,能描述4个维度的数组。 + +## 矩阵乘法 + +* 批量的线性变换。 + +* 非方阵。行缺失,表示主成分保留,次要维度省略。 +* 非方阵。行增加,表示补充了次要成分。 \ No newline at end of file diff --git a/线性代数/img/线性变换.png b/线性代数/img/线性变换.png new file mode 100644 index 00000000..0cc07e63 Binary files /dev/null and b/线性代数/img/线性变换.png differ