mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-03-21 02:10:11 +08:00
Merge remote-tracking branch 'LCTT/master'
This commit is contained in:
commit
1a20bc3797
@ -1,10 +1,11 @@
|
||||
如何在 Linux 中列出可用的软件包组
|
||||
======
|
||||
|
||||
我们知道,如果想要在 Linux 中安装软件包,可以使用软件包管理器来进行安装。由于系统管理员需要频繁用到软件包管理器,所以它是 Linux 当中的一个重要工具。
|
||||
|
||||
但是如果想一次性安装一个软件包组,在 Linux 中有可能吗?又如何通过命令去实现呢?
|
||||
|
||||
在 Linux 中确实可以用软件包管理器来达到这样的目的。很多软件包管理器都有这样的选项来实现这个功能,但就我所知,`apt` 或 `apt-get` 软件包管理器却并没有这个选项。因此对基于 Debian 的系统,需要使用的命令是 `tasksel`,而不是 `apt`或 `apt-get` 这样的官方软件包管理器。
|
||||
在 Linux 中确实可以用软件包管理器来达到这样的目的。很多软件包管理器都有这样的选项来实现这个功能,但就我所知,`apt` 或 `apt-get` 软件包管理器却并没有这个选项。因此对基于 Debian 的系统,需要使用的命令是 `tasksel`,而不是 `apt` 或 `apt-get` 这样的官方软件包管理器。
|
||||
|
||||
在 Linux 中安装软件包组有很多好处。对于 LAMP 来说,安装过程会包含多个软件包,但如果安装软件包组命令来安装,只安装一个包就可以了。
|
||||
|
||||
@ -13,19 +14,20 @@
|
||||
软件包组是一组用于公共功能的软件包,包括系统工具、声音和视频。 安装软件包组的过程中,会获取到一系列的依赖包,从而大大节省了时间。
|
||||
|
||||
**推荐阅读:**
|
||||
**(#)** [如何在 Linux 上按照大小列出已安装的软件包][1]
|
||||
**(#)** [如何在 Linux 上查看/列出可用的软件包更新][2]
|
||||
**(#)** [如何在 Linux 上查看软件包的安装/更新/升级/移除/卸载时间][3]
|
||||
**(#)** [如何在 Linux 上查看一个软件包的详细信息][4]
|
||||
**(#)** [如何查看一个软件包是否在你的 Linux 发行版上可用][5]
|
||||
**(#)** [萌新指导:一个可视化的 Linux 包管理工具][6]
|
||||
**(#)** [老手必会:命令行软件包管理器的用法][7]
|
||||
|
||||
- [如何在 Linux 上按照大小列出已安装的软件包][1]
|
||||
- [如何在 Linux 上查看/列出可用的软件包更新][2]
|
||||
- [如何在 Linux 上查看软件包的安装/更新/升级/移除/卸载时间][3]
|
||||
- [如何在 Linux 上查看一个软件包的详细信息][4]
|
||||
- [如何查看一个软件包是否在你的 Linux 发行版上可用][5]
|
||||
- [萌新指导:一个可视化的 Linux 包管理工具][6]
|
||||
- [老手必会:命令行软件包管理器的用法][7]
|
||||
|
||||
### 如何在 CentOS/RHEL 系统上列出可用的软件包组
|
||||
|
||||
RHEL 和 CentOS 系统使用的是 RPM 软件包,因此可以使用 `yum` 软件包管理器来获取相关的软件包信息。
|
||||
|
||||
`yum` 是 Yellowdog Updater, Modified 的缩写,它是一个用于基于 RPM 系统(例如 RHEL 和 CentOS)的,开源的命令行软件包管理工具。它是从分发库或其它第三方库中获取、安装、删除、查询和管理 RPM 包的主要工具。
|
||||
`yum` 是 “Yellowdog Updater, Modified” 的缩写,它是一个用于基于 RPM 系统(例如 RHEL 和 CentOS)的,开源的命令行软件包管理工具。它是从发行版仓库或其它第三方库中获取、安装、删除、查询和管理 RPM 包的主要工具。
|
||||
|
||||
**推荐阅读:** [使用 yum 命令在 RHEL/CentOS 系统上管理软件包][8]
|
||||
|
||||
@ -69,10 +71,9 @@ Available Language Groups:
|
||||
.
|
||||
.
|
||||
Done
|
||||
|
||||
```
|
||||
|
||||
如果需要列出相关联的软件包,可以执行以下这个命令。下面的例子是列出和 Performance Tools 组相关联的软件包。
|
||||
如果需要列出相关联的软件包,可以执行以下这个命令。下面的例子是列出和 “Performance Tools” 组相关联的软件包。
|
||||
|
||||
```
|
||||
# yum groupinfo "Performance Tools"
|
||||
@ -103,18 +104,17 @@ Group: Performance Tools
|
||||
tiobench
|
||||
tuned
|
||||
tuned-utils
|
||||
|
||||
```
|
||||
|
||||
### 如何在 Fedora 系统上列出可用的软件包组
|
||||
|
||||
Fedora 系统使用的是 DNF 软件包管理器,因此可以通过 DNF 软件包管理器来获取相关的信息。
|
||||
|
||||
DNF 的含义是 Dandified yum。、DNF 软件包管理器是 YUM 软件包管理器的一个分支,它使用 hawkey/libsolv 库作为后端。从 Fedora 18 开始,Aleš Kozumplík 开始着手 DNF 的开发,直到在Fedora 22 开始加入到系统中。
|
||||
DNF 的含义是 “Dandified yum”。DNF 软件包管理器是 YUM 软件包管理器的一个分支,它使用 hawkey/libsolv 库作为后端。从 Fedora 18 开始,Aleš Kozumplík 开始着手 DNF 的开发,直到在 Fedora 22 开始加入到系统中。
|
||||
|
||||
`dnf` 命令可以在 Fedora 22 及更高版本上安装、更新、搜索和删除软件包, 它可以自动解决软件包的依赖关系并其顺利安装,不会产生问题。
|
||||
|
||||
由于一些长期未被解决的问题的存在,YUM 被 DNF 逐渐取代了。而 Aleš Kozumplík 的 DNF 却并未对 yum 的这些问题作出修补,他认为这是技术上的难题,YUM 团队也从不接受这些更改。而且 YUM 的代码量有 5.6 万行,而 DNF 只有 2.9 万行。因此已经不需要沿着 YUM 的方向继续开发了,重新开一个分支才是更好的选择。
|
||||
YUM 被 DNF 取代是由于 YUM 中存在一些长期未被解决的问题。为什么 Aleš Kozumplík 没有对 yum 的这些问题作出修补呢,他认为补丁解决存在技术上的难题,而 YUM 团队也不会马上接受这些更改,还有一些重要的问题。而且 YUM 的代码量有 5.6 万行,而 DNF 只有 2.9 万行。因此已经不需要沿着 YUM 的方向继续开发了,重新开一个分支才是更好的选择。
|
||||
|
||||
**推荐阅读:** [在 Fedora 系统上使用 DNF 命令管理软件包][9]
|
||||
|
||||
@ -167,13 +167,11 @@ Available Groups:
|
||||
Hardware Support
|
||||
Sound and Video
|
||||
System Tools
|
||||
|
||||
```
|
||||
|
||||
如果需要列出相关联的软件包,可以执行以下这个命令。下面的例子是列出和 Editor 组相关联的软件包。
|
||||
如果需要列出相关联的软件包,可以执行以下这个命令。下面的例子是列出和 “Editor” 组相关联的软件包。
|
||||
|
||||
```
|
||||
|
||||
# dnf groupinfo Editors
|
||||
Last metadata expiration check: 0:04:57 ago on Sun 09 Sep 2018 07:10:36 PM IST.
|
||||
|
||||
@ -267,7 +265,7 @@ i | yast2_basis | 20150918-25.1 | @System |
|
||||
| yast2_install_wf | 20150918-25.1 | Main Repository (OSS) |
|
||||
```
|
||||
|
||||
如果需要列出相关联的软件包,可以执行以下这个命令。下面的例子是列出和 file_server 组相关联的软件包。另外 `zypper` 还允许用户使用不同的选项执行相同的操作。
|
||||
如果需要列出相关联的软件包,可以执行以下这个命令。下面的例子是列出和 “file_server” 组相关联的软件包。另外 `zypper` 还允许用户使用不同的选项执行相同的操作。
|
||||
|
||||
```
|
||||
# zypper info file_server
|
||||
@ -346,7 +344,7 @@ Contents :
|
||||
| yast2-tftp-server | package | Recommended
|
||||
```
|
||||
|
||||
如果需要列出相关联的软件包,可以执行以下这个命令。
|
||||
如果需要列出相关联的软件包,也可以执行以下这个命令。
|
||||
|
||||
```
|
||||
# zypper info pattern file_server
|
||||
@ -385,7 +383,7 @@ Contents :
|
||||
| yast2-tftp-server | package | Recommended
|
||||
```
|
||||
|
||||
如果需要列出相关联的软件包,可以执行以下这个命令。
|
||||
如果需要列出相关联的软件包,也可以执行以下这个命令。
|
||||
|
||||
```
|
||||
# zypper info -t pattern file_server
|
||||
@ -431,7 +429,7 @@ Contents :
|
||||
|
||||
[tasksel][11] 是 Debian/Ubuntu 系统上一个很方便的工具,只需要很少的操作就可以用它来安装好一组软件包。可以在 `/usr/share/tasksel` 目录下的 `.desc` 文件中安排软件包的安装任务。
|
||||
|
||||
默认情况下,`tasksel` 工具是作为 Debian 系统的一部分安装的,但桌面版 Ubuntu 则没有自带 `tasksel`,类似软件包管理器中的元包(meta-packages)。
|
||||
默认情况下,`tasksel` 工具是作为 Debian 系统的一部分安装的,但桌面版 Ubuntu 则没有自带 `tasksel`,这个功能类似软件包管理器中的元包(meta-packages)。
|
||||
|
||||
`tasksel` 工具带有一个基于 zenity 的简单用户界面,例如命令行中的弹出图形对话框。
|
||||
|
||||
@ -483,7 +481,7 @@ u openssh-server OpenSSH server
|
||||
u server Basic Ubuntu server
|
||||
```
|
||||
|
||||
如果需要列出相关联的软件包,可以执行以下这个命令。下面的例子是列出和 lamp-server 组相关联的软件包。
|
||||
如果需要列出相关联的软件包,可以执行以下这个命令。下面的例子是列出和 “lamp-server” 组相关联的软件包。
|
||||
|
||||
```
|
||||
# tasksel --task-desc "lamp-server"
|
||||
@ -494,7 +492,7 @@ Selects a ready-made Linux/Apache/MySQL/PHP server.
|
||||
|
||||
基于 Arch Linux 的系统使用的是 pacman 软件包管理器,因此可以通过 pacman 软件包管理器来获取相关的信息。
|
||||
|
||||
pacman 是 package manager 的缩写。`pacman` 可以用于安装、构建、删除和管理 Arch Linux 软件包。`pacman` 使用 libalpm(Arch Linux Package Management 库,ALPM)作为后端来执行所有操作。
|
||||
pacman 是 “package manager” 的缩写。`pacman` 可以用于安装、构建、删除和管理 Arch Linux 软件包。`pacman` 使用 libalpm(Arch Linux Package Management 库,ALPM)作为后端来执行所有操作。
|
||||
|
||||
**推荐阅读:** [使用 pacman 在基于 Arch Linux 的系统上管理软件包][13]
|
||||
|
||||
@ -536,10 +534,9 @@ realtime
|
||||
sugar-fructose
|
||||
tesseract-data
|
||||
vim-plugins
|
||||
|
||||
```
|
||||
|
||||
如果需要列出相关联的软件包,可以执行以下这个命令。下面的例子是列出和 gnome 组相关联的软件包。
|
||||
如果需要列出相关联的软件包,可以执行以下这个命令。下面的例子是列出和 “gnome” 组相关联的软件包。
|
||||
|
||||
```
|
||||
# pacman -Sg gnome
|
||||
@ -603,7 +600,6 @@ Interrupt signal received
|
||||
```
|
||||
# pacman -Sg gnome | wc -l
|
||||
64
|
||||
|
||||
```
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
@ -613,7 +609,7 @@ via: https://www.2daygeek.com/how-to-list-an-available-package-groups-in-linux/
|
||||
作者:[Prakash Subramanian][a]
|
||||
选题:[lujun9972](https://github.com/lujun9972)
|
||||
译者:[HankChow](https://github.com/HankChow)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
@ -0,0 +1,239 @@
|
||||
如何将 Scikit-learn Python 库用于数据科学项目
|
||||
======
|
||||
|
||||
> 灵活多样的 Python 库为数据分析和数据挖掘提供了强力的机器学习工具。
|
||||
|
||||

|
||||
|
||||
Scikit-learn Python 库最初于 2007 年发布,通常用于解决各种方面的机器学习和数据科学问题。这个多种功能的库提供了整洁、一致、高效的 API 和全面的在线文档。
|
||||
|
||||
### 什么是 Scikit-learn?
|
||||
|
||||
[Scikit-learn][1] 是一个开源 Python 库,拥有强大的数据分析和数据挖掘工具。 在 BSD 许可下可用,并建立在以下机器学习库上:
|
||||
|
||||
- `NumPy`,一个用于操作多维数组和矩阵的库。它还具有广泛的数学函数汇集,可用于执行各种计算。
|
||||
- `SciPy`,一个由各种库组成的生态系统,用于完成技术计算任务。
|
||||
- `Matplotlib`,一个用于绘制各种图表和图形的库。
|
||||
|
||||
Scikit-learn 提供了广泛的内置算法,可以充分用于数据科学项目。
|
||||
|
||||
以下是使用 Scikit-learn 库的主要方法。
|
||||
|
||||
#### 1、分类
|
||||
|
||||
[分类][2]工具识别与提供的数据相关联的类别。例如,它们可用于将电子邮件分类为垃圾邮件或非垃圾邮件。
|
||||
|
||||
Scikit-learn 中的分类算法包括:
|
||||
|
||||
- <ruby>支持向量机<rt>Support vector machines</rt></ruby>(SVM)
|
||||
- <ruby>最邻近<rt>Nearest neighbors</rt></ruby>
|
||||
- <ruby>随机森林<rt>Random forest</rt></ruby>
|
||||
|
||||
#### 2、回归
|
||||
|
||||
回归涉及到创建一个模型去试图理解输入和输出数据之间的关系。例如,回归工具可用于理解股票价格的行为。
|
||||
|
||||
回归算法包括:
|
||||
|
||||
- <ruby>支持向量机<rt>Support vector machines</rt></ruby>(SVM)
|
||||
- <ruby>岭回归<rt>Ridge regression</rt></ruby>
|
||||
- Lasso(LCTT 译注:Lasso 即 least absolute shrinkage and selection operator,又译为最小绝对值收敛和选择算子、套索算法)
|
||||
|
||||
#### 3、聚类
|
||||
|
||||
Scikit-learn 聚类工具用于自动将具有相同特征的数据分组。 例如,可以根据客户数据的地点对客户数据进行细分。
|
||||
|
||||
聚类算法包括:
|
||||
|
||||
- K-means
|
||||
- <ruby>谱聚类<rt>Spectral clustering</rt></ruby>
|
||||
- Mean-shift
|
||||
|
||||
#### 4、降维
|
||||
|
||||
降维降低了用于分析的随机变量的数量。例如,为了提高可视化效率,可能不会考虑外围数据。
|
||||
|
||||
降维算法包括:
|
||||
|
||||
- <ruby>主成分分析<rt>Principal component analysis</rt></ruby>(PCA)
|
||||
- <ruby>功能选择<rt>Feature selection</rt></ruby>
|
||||
- <ruby>非负矩阵分解<rt>Non-negative matrix factorization</rt></ruby>
|
||||
|
||||
#### 5、模型选择
|
||||
|
||||
模型选择算法提供了用于比较、验证和选择要在数据科学项目中使用的最佳参数和模型的工具。
|
||||
|
||||
通过参数调整能够增强精度的模型选择模块包括:
|
||||
|
||||
- <ruby>网格搜索<rt>Grid search</rt></ruby>
|
||||
- <ruby>交叉验证<rt>Cross-validation</rt></ruby>
|
||||
- <ruby>指标<rt>Metrics</rt></ruby>
|
||||
|
||||
#### 6、预处理
|
||||
|
||||
Scikit-learn 预处理工具在数据分析期间的特征提取和规范化中非常重要。 例如,您可以使用这些工具转换输入数据(如文本)并在分析中应用其特征。
|
||||
|
||||
预处理模块包括:
|
||||
|
||||
- 预处理
|
||||
- 特征提取
|
||||
|
||||
### Scikit-learn 库示例
|
||||
|
||||
让我们用一个简单的例子来说明如何在数据科学项目中使用 Scikit-learn 库。
|
||||
|
||||
我们将使用[鸢尾花花卉数据集][3],该数据集包含在 Scikit-learn 库中。 鸢尾花数据集包含有关三种花种的 150 个细节,三种花种分别为:
|
||||
|
||||
- Setosa:标记为 0
|
||||
- Versicolor:标记为 1
|
||||
- Virginica:标记为 2
|
||||
|
||||
数据集包括每种花种的以下特征(以厘米为单位):
|
||||
|
||||
- 萼片长度
|
||||
- 萼片宽度
|
||||
- 花瓣长度
|
||||
- 花瓣宽度
|
||||
|
||||
#### 第 1 步:导入库
|
||||
|
||||
由于鸢尾花花卉数据集包含在 Scikit-learn 数据科学库中,我们可以将其加载到我们的工作区中,如下所示:
|
||||
|
||||
```
|
||||
from sklearn import datasets
|
||||
iris = datasets.load_iris()
|
||||
```
|
||||
|
||||
这些命令从 `sklearn` 导入数据集 `datasets` 模块,然后使用 `datasets` 中的 `load_iris()` 方法将数据包含在工作空间中。
|
||||
|
||||
#### 第 2 步:获取数据集特征
|
||||
|
||||
数据集 `datasets` 模块包含几种方法,使您更容易熟悉处理数据。
|
||||
|
||||
在 Scikit-learn 中,数据集指的是类似字典的对象,其中包含有关数据的所有详细信息。 使用 `.data` 键存储数据,该数据列是一个数组列表。
|
||||
|
||||
例如,我们可以利用 `iris.data` 输出有关鸢尾花花卉数据集的信息。
|
||||
|
||||
```
|
||||
print(iris.data)
|
||||
```
|
||||
|
||||
这是输出(结果已被截断):
|
||||
|
||||
```
|
||||
[[5.1 3.5 1.4 0.2]
|
||||
[4.9 3. 1.4 0.2]
|
||||
[4.7 3.2 1.3 0.2]
|
||||
[4.6 3.1 1.5 0.2]
|
||||
[5. 3.6 1.4 0.2]
|
||||
[5.4 3.9 1.7 0.4]
|
||||
[4.6 3.4 1.4 0.3]
|
||||
[5. 3.4 1.5 0.2]
|
||||
[4.4 2.9 1.4 0.2]
|
||||
[4.9 3.1 1.5 0.1]
|
||||
[5.4 3.7 1.5 0.2]
|
||||
[4.8 3.4 1.6 0.2]
|
||||
[4.8 3. 1.4 0.1]
|
||||
[4.3 3. 1.1 0.1]
|
||||
[5.8 4. 1.2 0.2]
|
||||
[5.7 4.4 1.5 0.4]
|
||||
[5.4 3.9 1.3 0.4]
|
||||
[5.1 3.5 1.4 0.3]
|
||||
```
|
||||
|
||||
我们还使用 `iris.target` 向我们提供有关花朵不同标签的信息。
|
||||
|
||||
```
|
||||
print(iris.target)
|
||||
```
|
||||
|
||||
这是输出:
|
||||
|
||||
```
|
||||
[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
|
||||
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2
|
||||
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
|
||||
2 2]
|
||||
```
|
||||
|
||||
如果我们使用 `iris.target_names`,我们将输出数据集中找到的标签名称的数组。
|
||||
|
||||
```
|
||||
print(iris.target_names)
|
||||
```
|
||||
|
||||
以下是运行 Python 代码后的结果:
|
||||
|
||||
```
|
||||
['setosa' 'versicolor' 'virginica']
|
||||
```
|
||||
|
||||
#### 第 3 步:可视化数据集
|
||||
|
||||
我们可以使用[箱形图][4]来生成鸢尾花数据集的视觉描绘。 箱形图说明了数据如何通过四分位数在平面上分布的。
|
||||
|
||||
以下是如何实现这一目标:
|
||||
|
||||
```
|
||||
import seaborn as sns
|
||||
box_data = iris.data # 表示数据数组的变量
|
||||
box_target = iris.target # 表示标签数组的变量
|
||||
sns.boxplot(data = box_data,width=0.5,fliersize=5)
|
||||
sns.set(rc={'figure.figsize':(2,15)})
|
||||
```
|
||||
|
||||
让我们看看结果:
|
||||
|
||||

|
||||
|
||||
在横轴上:
|
||||
|
||||
* 0 是萼片长度
|
||||
* 1 是萼片宽度
|
||||
* 2 是花瓣长度
|
||||
* 3 是花瓣宽度
|
||||
|
||||
垂直轴的尺寸以厘米为单位。
|
||||
|
||||
### 总结
|
||||
|
||||
以下是这个简单的 Scikit-learn 数据科学教程的完整代码。
|
||||
|
||||
```
|
||||
from sklearn import datasets
|
||||
iris = datasets.load_iris()
|
||||
print(iris.data)
|
||||
print(iris.target)
|
||||
print(iris.target_names)
|
||||
import seaborn as sns
|
||||
box_data = iris.data # 表示数据数组的变量
|
||||
box_target = iris.target # 表示标签数组的变量
|
||||
sns.boxplot(data = box_data,width=0.5,fliersize=5)
|
||||
sns.set(rc={'figure.figsize':(2,15)})
|
||||
```
|
||||
|
||||
Scikit-learn 是一个多功能的 Python 库,可用于高效完成数据科学项目。
|
||||
|
||||
如果您想了解更多信息,请查看 [LiveEdu][5] 上的教程,例如 Andrey Bulezyuk 关于使用 Scikit-learn 库创建[机器学习应用程序][6]的视频。
|
||||
|
||||
有什么评价或者疑问吗? 欢迎在下面分享。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/18/9/how-use-scikit-learn-data-science-projects
|
||||
|
||||
作者:[Dr.Michael J.Garbade][a]
|
||||
选题:[lujun9972](https://github.com/lujun9972)
|
||||
译者:[Flowsnow](https://github.com/Flowsnow)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/drmjg
|
||||
[1]: http://scikit-learn.org/stable/index.html
|
||||
[2]: https://blog.liveedu.tv/regression-versus-classification-machine-learning-whats-the-difference/
|
||||
[3]: https://en.wikipedia.org/wiki/Iris_flower_data_set
|
||||
[4]: https://en.wikipedia.org/wiki/Box_plot
|
||||
[5]: https://www.liveedu.tv/guides/data-science/
|
||||
[6]: https://www.liveedu.tv/andreybu/REaxr-machine-learning-model-python-sklearn-kera/oPGdP-machine-learning-model-python-sklearn-kera/
|
@ -1,3 +1,6 @@
|
||||
Translating by MjSeven
|
||||
|
||||
|
||||
# [Improve your Bash scripts with Argbash][1]
|
||||
|
||||

|
||||
|
@ -1,191 +0,0 @@
|
||||
FSSlc Translating
|
||||
How To Lock The Keyboard And Mouse, But Not The Screen In Linux
|
||||
======
|
||||
|
||||

|
||||
|
||||
My 4-years-old niece is a curious-kid. She loves “Avatar” movie very much. When the Avatar movie is on, she became so focused and her eyes are glued to the screen. But the problem is she often touches a key in the keyboard or move the mouse or click the mouse button while watching the movie. Sometimes, she accidentally close or pause the movie by pressing a key in the keyboard. So I was looking for a way to lock down both the keyboard and mouse, but not the screen. Luckily, I came across a perfect solution in Ubuntu forum. If you don’t want your cat or puppy walking on your keyboard or your kid messing up with the keyboard and mouse while you watching something important on the screen, I suggest you to try **“xtrlock”** utility. It is a simple, yet useful utility to lock the X display till the user enters their password at the keyboard. In this brief tutorial, I will show you how to lock the keyboard and mouse, but not the screen in Linux. This trick will work on all Linux operating systems.
|
||||
|
||||
### Install xtrlock
|
||||
|
||||
The xtrlock package is available in the default repositories of most Linux operating systems. So, you can install it using your distribution’s package manager.
|
||||
|
||||
On **Arch Linux** and derivatives, run the following command to install it.
|
||||
```
|
||||
$ sudo pacman -S xtrlock
|
||||
|
||||
```
|
||||
|
||||
On **Fedora** :
|
||||
```
|
||||
$ sudo dnf install xtrlock
|
||||
|
||||
```
|
||||
|
||||
On **RHEL, CentOS** :
|
||||
```
|
||||
$ sudo yum install xtrlock
|
||||
|
||||
```
|
||||
|
||||
On **SUSE/openSUSE** :
|
||||
```
|
||||
$ sudo zypper install xtrlock
|
||||
|
||||
```
|
||||
|
||||
On **Debian, Ubuntu, Linux Mint** :
|
||||
```
|
||||
$ sudo apt-get install xtrlock
|
||||
|
||||
```
|
||||
|
||||
### Lock the Keyboard and Mouse, but not the Screen using xtrlock
|
||||
|
||||
Once xtrlock installed, create a keyboard shortcut. You need this to lock the keyboard and mouse using the key combination of your choice.
|
||||
|
||||
Create a new file called **lockkbmouse** in **/usr/local/bin**.
|
||||
```
|
||||
$ sudo vi /usr/local/bin/lockkbmouse
|
||||
|
||||
```
|
||||
|
||||
Add the following lines into it.
|
||||
```
|
||||
#!/bin/bash
|
||||
sleep 1 && xtrlock
|
||||
|
||||
```
|
||||
|
||||
Save the file and close the file.
|
||||
|
||||
Make it as executable using the following command:
|
||||
```
|
||||
$ sudo chmod a+x /usr/local/bin/lockkbmouse
|
||||
|
||||
```
|
||||
|
||||
Next, we need to create keyboard a shortcut.
|
||||
|
||||
**In Arch Linux MATE desktop:**
|
||||
|
||||
Go to **System - > Preferences -> Hardware -> keyboard Shortcuts**.
|
||||
|
||||
Click **Add** to create a new shortcut.
|
||||
|
||||
![][2]
|
||||
|
||||
Enter the name for your shortcut and add the following line in the command box, and click **Apply** button.
|
||||
```
|
||||
bash -c "sleep 1 && xtrlock"
|
||||
|
||||
```
|
||||
|
||||
![][3]
|
||||
|
||||
To assign the shortcut key, just select or double click on it and type the key combination of your choice. For example, I use **Alt+k**.
|
||||
|
||||
![][4]
|
||||
|
||||
To clear the key combination, press BACKSPACE key. Once you finished, close the Keyboard Settings window.
|
||||
|
||||
**In Ubuntu GNOME DE:**
|
||||
|
||||
Go to **System Settings - > Devices -> Keyboard**. Click the **+** symbol at the end.
|
||||
|
||||
Enter the name for your shortcut and add the following line in the command box, and click **Add** button.
|
||||
```
|
||||
bash -c "sleep 1 && xtrlock"
|
||||
|
||||
```
|
||||
|
||||
![][5]
|
||||
|
||||
Next, assign the shortcut key to the newly created shortcut. To do so, just select or double click on it and click on **“Set shortcut”** button.
|
||||
|
||||
![][6]
|
||||
|
||||
You will now see the following screen.
|
||||
|
||||
![][7]
|
||||
|
||||
Type the key combination of your choice. For example, I use **Alt+k**.
|
||||
|
||||
![][8]
|
||||
|
||||
To clear the key combination, press BACKSPACE key. The shortcut key has been assigned. Once you finished, close the Keyboard Settings window.
|
||||
|
||||
From now on, whenever you press the keyboard shortcut key (ALT+k in our case), the mouse pointer will turn into a a padlock. Now, the keyboard and mouse have been locked, so you can freely watch the movies or whatever you want to. Even your kid or pet touches some keys on the keyboard or clicks a mouse button, they won’t work.
|
||||
|
||||
Here is xtrclock in action.
|
||||
|
||||
![][9]
|
||||
|
||||
Do you see the a small lock button? It means that the keyboard and mouse have been locked. Even if you move the lock button, nothing will happen. The task in the background will keep running until you unlock your screen and manually close the running task.
|
||||
|
||||
### Unlock keyboard and mouse
|
||||
|
||||
To unlock the keyboard and mouse, simply type your password and hit “Enter”. You will not see the password as you type it. Just type the password anyway and hit ENTER key. The mouse and keyboard will start to work after you entered the correct password. If you entered an incorrect password, you will hear a bell sound. Press **ESC** key to clear the incorrect password and re-enter the correct password again. To remove one character of a partially typed password, press either **BACKSPACE** or **DELETE** keys.
|
||||
|
||||
### What if I permanently get locked out of the screen?
|
||||
|
||||
The xtrclock tool may not work on some DEs, for example GDM. It may permanently lock you out of the screen. Please test it in a virtual machine and then try it in your personal or official desktop if it really works. I tested this on Arch Linux MATE desktop and Ubuntu 18.04 GNOME desktop. It worked just fine.
|
||||
|
||||
Just in case, you are locked out of the screen permanently, switch to the TTY (CTRL+ALT+F2) then run:
|
||||
```
|
||||
$ sudo killall xtrlock
|
||||
|
||||
```
|
||||
|
||||
Alternatively, you can use the **chvt** command to switch between TTY and X session.
|
||||
|
||||
For example, to switch to TTY1, run:
|
||||
```
|
||||
$ sudo chvt 1
|
||||
|
||||
```
|
||||
|
||||
To switch back to the X session again, type:
|
||||
```
|
||||
$ sudo chvt 7
|
||||
|
||||
```
|
||||
|
||||
Different distros uses different key combinations to switch between TTYs. Please refer your distribution’s official website for more details.
|
||||
|
||||
For more details about xtrlock, refer man pages.
|
||||
```
|
||||
$ man xtrlock
|
||||
|
||||
```
|
||||
|
||||
And, that’s all for now. Hope this helps. If you find our guides useful, please spend a moment to share them on your social, professional networks and support OSTechNix.
|
||||
|
||||
**Resource:**
|
||||
|
||||
* [**Ubuntu forum**][10]
|
||||
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.ostechnix.com/lock-keyboard-mouse-not-screen-linux/
|
||||
|
||||
作者:[SK][a]
|
||||
选题:[lujun9972](https://github.com/lujun9972)
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://www.ostechnix.com/author/sk/
|
||||
[1]:data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7
|
||||
[2]:http://www.ostechnix.com/wp-content/uploads/2017/09/Keyboard-Shortcuts_001.png
|
||||
[3]:http://www.ostechnix.com/wp-content/uploads/2017/09/Keyboard-Shortcuts_002.png
|
||||
[4]:http://www.ostechnix.com/wp-content/uploads/2017/09/Keyboard-Shortcuts_003.png
|
||||
[5]:http://www.ostechnix.com/wp-content/uploads/2018/01/Add-xtrlock-shortcut.png
|
||||
[6]:http://www.ostechnix.com/wp-content/uploads/2018/01/set-shortcut-key-1.png
|
||||
[7]:http://www.ostechnix.com/wp-content/uploads/2018/01/set-shortcut-key-2.png
|
||||
[8]:http://www.ostechnix.com/wp-content/uploads/2018/01/set-shortcut-key-3.png
|
||||
[9]:http://www.ostechnix.com/wp-content/uploads/2018/01/xtrclock-1.png
|
||||
[10]:https://ubuntuforums.org/showthread.php?t=993800
|
@ -1,3 +1,5 @@
|
||||
translating by ypingcn
|
||||
|
||||
Control your data with Syncthing: An open source synchronization tool
|
||||
======
|
||||
Decide how to store and share your personal information.
|
||||
|
@ -1,3 +1,5 @@
|
||||
translating---geekpi
|
||||
|
||||
5 cool tiling window managers
|
||||
======
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
[translating by jrg 20181014]
|
||||
|
||||
Using Grails with jQuery and DataTables
|
||||
======
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
[translating by jrg, 20181014]
|
||||
|
||||
16 iptables tips and tricks for sysadmins
|
||||
======
|
||||
Iptables provides powerful capabilities to control traffic coming in and out of your system.
|
||||
|
@ -1,72 +0,0 @@
|
||||
translating---geekpi
|
||||
|
||||
Introducing Swift on Fedora
|
||||
======
|
||||
|
||||

|
||||
|
||||
Swift is a general-purpose programming language built using a modern approach to safety, performance, and software design patterns. It aims to be the best language for a variety of programming projects, ranging from systems programming to desktop applications and scaling up to cloud services. Read more about it and how to try it out in Fedora.
|
||||
|
||||
### Safe, Fast, Expressive
|
||||
|
||||
Like many modern programming languages, Swift was designed to be safer than C-based languages. For example, variables are always initialized before they can be used. Arrays and integers are checked for overflow. Memory is automatically managed.
|
||||
|
||||
Swift puts intent right in the syntax. To declare a variable, use the var keyword. To declare a constant, use let.
|
||||
|
||||
Swift also guarantees that objects can never be nil; in fact, trying to use an object known to be nil will cause a compile-time error. When using a nil value is appropriate, it supports a mechanism called **optionals**. An optional may contain nil, but is safely unwrapped using the **?** operator.
|
||||
|
||||
Some additional features include:
|
||||
|
||||
* Closures unified with function pointers
|
||||
* Tuples and multiple return values
|
||||
* Generics
|
||||
* Fast and concise iteration over a range or collection
|
||||
* Structs that support methods, extensions, and protocols
|
||||
* Functional programming patterns, e.g., map and filter
|
||||
* Powerful error handling built-in
|
||||
* Advanced control flow with do, guard, defer, and repeat keywords
|
||||
|
||||
|
||||
|
||||
### Try Swift out
|
||||
|
||||
Swift is available in Fedora 28 under then package name **swift-lang**. Once installed, run swift and the REPL console starts up.
|
||||
|
||||
```
|
||||
$ swift
|
||||
Welcome to Swift version 4.2 (swift-4.2-RELEASE). Type :help for assistance.
|
||||
1> let greeting="Hello world!"
|
||||
greeting: String = "Hello world!"
|
||||
2> print(greeting)
|
||||
Hello world!
|
||||
3> greeting = "Hello universe!"
|
||||
error: repl.swift:3:10: error: cannot assign to value: 'greeting' is a 'let' constant
|
||||
greeting = "Hello universe!"
|
||||
~~~~~~~~ ^
|
||||
|
||||
|
||||
3>
|
||||
|
||||
```
|
||||
|
||||
Swift has a growing community, and in particular, a [work group][1] dedicated to making it an efficient and effective server-side programming language. Be sure to visit [its home page][2] for more ways to get involved.
|
||||
|
||||
Photo by [Uillian Vargas][3] on [Unsplash][4].
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://fedoramagazine.org/introducing-swift-fedora/
|
||||
|
||||
作者:[Link Dupont][a]
|
||||
选题:[lujun9972](https://github.com/lujun9972)
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://fedoramagazine.org/author/linkdupont/
|
||||
[1]: https://swift.org/server/
|
||||
[2]: http://swift.org
|
||||
[3]: https://unsplash.com/photos/7oJpVR1inGk?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText
|
||||
[4]: https://unsplash.com/search/photos/fast?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText
|
@ -1,3 +1,5 @@
|
||||
translating by hopefully2333
|
||||
|
||||
Play Windows games on Fedora with Steam Play and Proton
|
||||
======
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
[translation by jrg]
|
||||
|
||||
An introduction to using tcpdump at the Linux command line
|
||||
======
|
||||
|
||||
|
@ -0,0 +1,171 @@
|
||||
如何在 Linux 下锁住键盘和鼠标而不锁屏
|
||||
======
|
||||
|
||||

|
||||
|
||||
我四岁的侄女是个好奇的孩子,她非常喜爱“阿凡达”电影,当阿凡达电影在播放时,她是如此的专注,好似眼睛粘在了屏幕上。但问题是当她观看电影时,她经常会碰到键盘上的某个键或者移动了鼠标,又或者是点击了鼠标的按钮。有时她非常意外地按了键盘上的某个键,从而将电影关闭或者暂停了。所以我就想找个方法来将键盘和鼠标都锁住,但屏幕不会被锁住。幸运的是,我在 Ubuntu 论坛上找到了一个完美的解决方法。假如在你正看着屏幕上的某些重要的事情时,你不想让你的小猫或者小狗在你的键盘上行走,或者让你的孩子在键盘上瞎搞一气,那我建议你试试 **xtrlock** 这个工具。它很简单但非常实用,你可以锁定屏幕的显示直到用户在键盘上输入自己设定的密码(译者注:就是用户自己的密码,例如用来打开屏保的那个密码,不需要单独设定)。在这篇简单的教程中,我将为你展示如何在 Linux 下锁住键盘和鼠标,而不锁掉屏幕。这个技巧几乎可以在所有的 Linux 操作系统中生效。
|
||||
|
||||
### 安装 xtrlock
|
||||
|
||||
xtrlock 软件包在大多数 Linux 操作系统的默认软件仓库中都可以获取到。所以你可以使用你安装的发行版的包管理器来安装它。
|
||||
|
||||
在 **Arch Linux** 及其衍生发行版中,运行下面的命令来安装它:
|
||||
```
|
||||
$ sudo pacman -S xtrlock
|
||||
```
|
||||
|
||||
在 **Fedora** 上使用:
|
||||
```
|
||||
$ sudo dnf install xtrlock
|
||||
```
|
||||
|
||||
在 **RHEL, CentOS** 上使用:
|
||||
```
|
||||
$ sudo yum install xtrlock
|
||||
```
|
||||
|
||||
在 **SUSE/openSUSE** 上使用:
|
||||
```
|
||||
$ sudo zypper install xtrlock
|
||||
```
|
||||
|
||||
在 **Debian, Ubuntu, Linux Mint** 上使用:
|
||||
```
|
||||
$ sudo apt-get install xtrlock
|
||||
```
|
||||
|
||||
### 使用 xtrlock 锁住键盘和鼠标但不锁屏
|
||||
|
||||
安装好 xtrlock 后,你需要根据你的选择来创建一个快捷键,通过这个快捷键来锁住键盘和鼠标。
|
||||
|
||||
在 **/usr/local/bin** 目录下创建一个名为 **lockkbmouse** 的新文件:
|
||||
```
|
||||
$ sudo vi /usr/local/bin/lockkbmouse
|
||||
```
|
||||
|
||||
然后将下面的命令添加到这个文件中:
|
||||
```
|
||||
#!/bin/bash
|
||||
sleep 1 && xtrlock
|
||||
```
|
||||
保存并关闭这个文件。
|
||||
|
||||
然后使用下面的命令来使得它可以被执行:
|
||||
```
|
||||
$ sudo chmod a+x /usr/local/bin/lockkbmouse
|
||||
```
|
||||
|
||||
接着,我们就需要创建快捷键了。
|
||||
|
||||
**在 Arch Linux MATE 桌面中**
|
||||
|
||||
依次点击 **System -> Preferences -> Hardware -> keyboard Shortcuts**
|
||||
|
||||
然后点击 **Add** 来创建快捷键。
|
||||
|
||||
![][2]
|
||||
|
||||
首先键入你的这个快捷键的名称,然后将下面的命令填入命令框中,最后点击 **Apply** 按钮。
|
||||
```
|
||||
bash -c "sleep 1 && xtrlock"
|
||||
```
|
||||
|
||||
![][3]
|
||||
|
||||
为了能够给这个快捷键赋予快捷方式,需要选中它或者双击它然后输入你选定的快捷键组合,例如我使用 **Alt+k** 这组快捷键。
|
||||
|
||||
![][4]
|
||||
|
||||
如果要清除这个快捷键组合,按住 `BACKSPACE` 键就可以了。完成后,关闭键盘设定窗口。
|
||||
|
||||
**在 Ubuntu GNOME 桌面中**
|
||||
|
||||
依次进入 **System Settings -> Devices -> Keyboard**,然后点击 **+** 这个符号。
|
||||
|
||||
键入你快捷键的名称并将下面的命令加到命令框里面,然后点击 **Add** 按钮。
|
||||
```
|
||||
bash -c "sleep 1 && xtrlock"
|
||||
```
|
||||
|
||||
![][5]
|
||||
|
||||
接下来为这个新建的快捷键赋予快捷方式。我们只需要选择或者双击 **“Set shortcut”** 这个按钮就可以了。
|
||||
|
||||
![][6]
|
||||
|
||||
然后你将看到下面的一屏。
|
||||
|
||||
![][7]
|
||||
|
||||
输入你选定的快捷键组合,例如我使用 **Alt+k**。
|
||||
|
||||
![][8]
|
||||
|
||||
如果要清除这个快捷键组合,则可以按 `BACKSPACE` 这个键。这样快捷键便设定好了,完成这个后,关闭键盘设定窗口。
|
||||
|
||||
从现在起,每当你输入刚才设定的快捷键(在我们的示例中是 `ATL+K`),鼠标的指针便会变成一个挂锁的模样。现在,键盘和鼠标便被锁定了,这时你便可以自在地观看你的电影或者做其他你想做的事儿。即便是你的孩子或者宠物碰了键盘上的某些键或者点击了鼠标,这些操作都不会起作用。
|
||||
|
||||
因为 `xtrlock` 已经在工作了。
|
||||
|
||||
![][9]
|
||||
|
||||
你看到了那个小的锁按钮了吗?它意味着键盘和鼠标已经被锁定了。即便你移动这个锁按钮,也不会发生任何事情。后台的任务在一直执行,直到你将屏幕解除,然后手动停掉运行中的任务。
|
||||
|
||||
### 将键盘和鼠标解锁
|
||||
|
||||
要将键盘和鼠标解锁,只需要输入你的密码然后敲击“Enter”键就可以了,在输入的过程中你将看不到密码。只需要输入然后敲 `ENTER` 键就可以了。在你输入了正确的密码后,鼠标和键盘就可以再工作了。假如你输入了一个错误的密码,你将听到警告声。按 **ESC** 来清除输入的错误密码,然后重新输入正确的密码。要去掉未完全输入完的密码中的一个字符,只需要按 **BACKSPACE** 或者 **DELETE** 键就可以了。
|
||||
|
||||
### 要是我被永久地锁住了怎么办?
|
||||
|
||||
以防你被永久地锁定了屏幕,切换至一个 TTY(例如 CTRL+ALT+F2)然后运行:
|
||||
```
|
||||
$ sudo killall xtrlock
|
||||
```
|
||||
|
||||
或者你还可以使用 **chvt** 命令来在 TTY 和 X 会话之间切换。
|
||||
|
||||
例如,如果要切换到 TTY1,则运行:
|
||||
```
|
||||
$ sudo chvt 1
|
||||
```
|
||||
|
||||
要切换回 X 会话,则键入:
|
||||
```
|
||||
$ sudo chvt 7
|
||||
```
|
||||
|
||||
不同的发行版使用了不同的快捷键组合来在不同的 TTY 间切换。请参考你安装的对应发行版的官方网站了解更多详情。
|
||||
|
||||
如果想知道更多 xtrlock 的信息,请参考 man 页:
|
||||
```
|
||||
$ man xtrlock
|
||||
```
|
||||
|
||||
那么这就是全部了。希望这个指南可以帮到你。假如你发现这个指南很有用,请花点时间将这个指南共享到你的朋友圈并支持我们(OSTechNix)。
|
||||
|
||||
**资源:**
|
||||
|
||||
* [**Ubuntu 论坛**][10]
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.ostechnix.com/lock-keyboard-mouse-not-screen-linux/
|
||||
|
||||
作者:[SK][a]
|
||||
选题:[lujun9972](https://github.com/lujun9972)
|
||||
译者:[FSSlc](https://github.com/FSSlc)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://www.ostechnix.com/author/sk/
|
||||
[1]:data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7
|
||||
[2]:http://www.ostechnix.com/wp-content/uploads/2017/09/Keyboard-Shortcuts_001.png
|
||||
[3]:http://www.ostechnix.com/wp-content/uploads/2017/09/Keyboard-Shortcuts_002.png
|
||||
[4]:http://www.ostechnix.com/wp-content/uploads/2017/09/Keyboard-Shortcuts_003.png
|
||||
[5]:http://www.ostechnix.com/wp-content/uploads/2018/01/Add-xtrlock-shortcut.png
|
||||
[6]:http://www.ostechnix.com/wp-content/uploads/2018/01/set-shortcut-key-1.png
|
||||
[7]:http://www.ostechnix.com/wp-content/uploads/2018/01/set-shortcut-key-2.png
|
||||
[8]:http://www.ostechnix.com/wp-content/uploads/2018/01/set-shortcut-key-3.png
|
||||
[9]:http://www.ostechnix.com/wp-content/uploads/2018/01/xtrlock-1.png
|
||||
[10]:https://ubuntuforums.org/showthread.php?t=993800
|
@ -1,238 +0,0 @@
|
||||
如何将Scikit-learn Python库用于数据科学项目
|
||||
======
|
||||
|
||||

|
||||
|
||||
Scikit-learn Python库最初于2007年发布,从头到尾都通常用于解决机器学习和数据科学问题。 多功能库提供整洁,一致,高效的API和全面的在线文档。
|
||||
|
||||
### 什么是Scikit-learn?
|
||||
|
||||
[Scikit-learn][1]是一个开源Python库,拥有强大的数据分析和数据挖掘工具。 在BSD许可下可用,并建立在以下机器学习库上:
|
||||
|
||||
- **NumPy**,一个用于操作多维数组和矩阵的库。 它还具有广泛的数学函数汇集,可用于执行各种计算。
|
||||
- **SciPy**,一个由各种库组成的生态系统,用于完成技术计算任务。
|
||||
- **Matplotlib**,一个用于绘制各种图表和图形的库。
|
||||
|
||||
Scikit-learn提供了广泛的内置算法,可以充分用于数据科学项目。
|
||||
|
||||
以下是使用Scikit-learn库的主要方法。
|
||||
|
||||
#### 1. 分类
|
||||
|
||||
[分类][2]工具识别与提供的数据相关联的类别。 例如,它们可用于将电子邮件分类为垃圾邮件或非垃圾邮件。
|
||||
|
||||
Scikit-learn中的分类算法包括:
|
||||
|
||||
- 支持向量机(SVM)
|
||||
- 最邻近
|
||||
- 随机森林
|
||||
|
||||
#### 2. 回归
|
||||
|
||||
回归涉及到创建一个模型去试图理解输入和输出数据之间的关系。 例如,回归工具可用于了解股票价格的行为。
|
||||
|
||||
回归算法包括:
|
||||
|
||||
- SVM
|
||||
- 岭回归Ridge regression
|
||||
- Lasso(LCTT译者注:Lasso 即 least absolute shrinkage and selection operator,又译最小绝对值收敛和选择算子、套索算法)
|
||||
|
||||
#### 3. 聚类
|
||||
|
||||
Scikit-learn聚类工具用于自动将具有相同特征的数据分组。 例如,可以根据客户数据的地点对客户数据进行细分。
|
||||
|
||||
聚类算法包括:
|
||||
|
||||
- K-means
|
||||
- 谱聚类Spectral clustering
|
||||
- Mean-shift
|
||||
|
||||
#### 4. 降维
|
||||
|
||||
降维降低了用于分析的随机变量的数量。 例如,为了提高可视化效率,可能不会考虑外围数据。
|
||||
|
||||
降维算法包括:
|
||||
|
||||
- 主成分分析Principal component analysis(PCA)
|
||||
- 功能选择Feature selection
|
||||
- 非负矩阵分解Non-negative matrix factorization
|
||||
|
||||
#### 5. 模型选择
|
||||
|
||||
模型选择算法提供了用于比较,验证和选择要在数据科学项目中使用的最佳参数和模型的工具。
|
||||
|
||||
通过参数调整能够增强精度的模型选择模块包括:
|
||||
|
||||
- 网格搜索Grid search
|
||||
- 交叉验证Cross-validation
|
||||
- 指标Metrics
|
||||
|
||||
#### 6. 预处理
|
||||
|
||||
Scikit-learn预处理工具在数据分析期间的特征提取和规范化中非常重要。 例如,您可以使用这些工具转换输入数据(如文本)并在分析中应用其特征。
|
||||
|
||||
预处理模块包括:
|
||||
|
||||
- 预处理
|
||||
- 特征提取
|
||||
|
||||
### Scikit-learn库示例
|
||||
|
||||
让我们用一个简单的例子来说明如何在数据科学项目中使用Scikit-learn库。
|
||||
|
||||
我们将使用[鸢尾花花卉数据集][3],该数据集包含在Scikit-learn库中。 鸢尾花数据集包含有关三种花种的150个细节,三种花种分别为:
|
||||
|
||||
- Setosa-标记为0
|
||||
- Versicolor-标记为1
|
||||
- Virginica-标记为2
|
||||
|
||||
数据集包括每种花种的以下特征(以厘米为单位):
|
||||
|
||||
- 萼片长度
|
||||
- 萼片宽度
|
||||
- 花瓣长度
|
||||
- 花瓣宽度
|
||||
|
||||
#### 第1步:导入库
|
||||
|
||||
由于Iris数据集包含在Scikit-learn数据科学库中,我们可以将其加载到我们的工作区中,如下所示:
|
||||
|
||||
```
|
||||
from sklearn import datasets
|
||||
iris = datasets.load_iris()
|
||||
```
|
||||
|
||||
这些命令从**sklearn**导入数据集**datasets**模块,然后使用**datasets**中的**load_iris()**方法将数据包含在工作空间中。
|
||||
|
||||
#### 第2步:获取数据集特征
|
||||
|
||||
数据集**datasets**模块包含几种方法,使您更容易熟悉处理数据。
|
||||
|
||||
在Scikit-learn中,数据集指的是类似字典的对象,其中包含有关数据的所有详细信息。 使用**.data**键存储数据,该数据列是一个数组列表。
|
||||
|
||||
例如,我们可以利用**iris.data**输出有关Iris花卉数据集的信息。
|
||||
|
||||
```
|
||||
print(iris.data)
|
||||
```
|
||||
|
||||
这是输出(结果已被截断):
|
||||
|
||||
```
|
||||
[[5.1 3.5 1.4 0.2]
|
||||
[4.9 3. 1.4 0.2]
|
||||
[4.7 3.2 1.3 0.2]
|
||||
[4.6 3.1 1.5 0.2]
|
||||
[5. 3.6 1.4 0.2]
|
||||
[5.4 3.9 1.7 0.4]
|
||||
[4.6 3.4 1.4 0.3]
|
||||
[5. 3.4 1.5 0.2]
|
||||
[4.4 2.9 1.4 0.2]
|
||||
[4.9 3.1 1.5 0.1]
|
||||
[5.4 3.7 1.5 0.2]
|
||||
[4.8 3.4 1.6 0.2]
|
||||
[4.8 3. 1.4 0.1]
|
||||
[4.3 3. 1.1 0.1]
|
||||
[5.8 4. 1.2 0.2]
|
||||
[5.7 4.4 1.5 0.4]
|
||||
[5.4 3.9 1.3 0.4]
|
||||
[5.1 3.5 1.4 0.3]
|
||||
```
|
||||
|
||||
我们还使用**iris.target**向我们提供有关花朵不同标签的信息。
|
||||
|
||||
```
|
||||
print(iris.target)
|
||||
```
|
||||
|
||||
这是输出:
|
||||
|
||||
```
|
||||
[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
|
||||
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2
|
||||
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
|
||||
2 2]
|
||||
|
||||
```
|
||||
|
||||
如果我们使用**iris.target_names**,我们将输出数据集中找到的标签名称的数组。
|
||||
|
||||
```
|
||||
print(iris.target_names)
|
||||
```
|
||||
|
||||
以下是运行Python代码后的结果:
|
||||
|
||||
```
|
||||
['setosa' 'versicolor' 'virginica']
|
||||
```
|
||||
|
||||
#### 第3步:可视化数据集
|
||||
|
||||
我们可以使用[箱形图][4]来生成鸢尾花数据集的视觉描绘。 箱形图说明了数据如何通过四分位数在平面上分布的。
|
||||
|
||||
以下是如何实现这一目标:
|
||||
|
||||
```
|
||||
import seaborn as sns
|
||||
box_data = iris.data # 表示数据数组的变量
|
||||
box_target = iris.target # 表示标签数组的变量
|
||||
sns.boxplot(data = box_data,width=0.5,fliersize=5)
|
||||
sns.set(rc={'figure.figsize':(2,15)})
|
||||
```
|
||||
|
||||
让我们看看结果:
|
||||
|
||||

|
||||
|
||||
在横轴上:
|
||||
|
||||
* 0是萼片长度
|
||||
* 1是萼片宽度
|
||||
* 2是花瓣长度
|
||||
* 3是花瓣宽度
|
||||
|
||||
垂直轴的尺寸以厘米为单位。
|
||||
|
||||
### 总结
|
||||
|
||||
以下是这个简单的Scikit-learn数据科学教程的完整代码。
|
||||
|
||||
```
|
||||
from sklearn import datasets
|
||||
iris = datasets.load_iris()
|
||||
print(iris.data)
|
||||
print(iris.target)
|
||||
print(iris.target_names)
|
||||
import seaborn as sns
|
||||
box_data = iris.data # 表示数据数组的变量
|
||||
box_target = iris.target # 表示标签数组的变量
|
||||
sns.boxplot(data = box_data,width=0.5,fliersize=5)
|
||||
sns.set(rc={'figure.figsize':(2,15)})
|
||||
```
|
||||
|
||||
Scikit-learn是一个多功能的Python库,可用于高效完成数据科学项目。
|
||||
|
||||
如果您想了解更多信息,请查看[LiveEdu][5]上的教程,例如Andrey Bulezyuk关于使用Scikit-learn库创建[机器学习应用程序][6]的视频。
|
||||
|
||||
有什么评价或者疑问吗? 欢迎在下面分享。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/18/9/how-use-scikit-learn-data-science-projects
|
||||
|
||||
作者:[Dr.Michael J.Garbade][a]
|
||||
选题:[lujun9972](https://github.com/lujun9972)
|
||||
译者:[Flowsnow](https://github.com/Flowsnow)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/drmjg
|
||||
[1]: http://scikit-learn.org/stable/index.html
|
||||
[2]: https://blog.liveedu.tv/regression-versus-classification-machine-learning-whats-the-difference/
|
||||
[3]: https://en.wikipedia.org/wiki/Iris_flower_data_set
|
||||
[4]: https://en.wikipedia.org/wiki/Box_plot
|
||||
[5]: https://www.liveedu.tv/guides/data-science/
|
||||
[6]: https://www.liveedu.tv/andreybu/REaxr-machine-learning-model-python-sklearn-kera/oPGdP-machine-learning-model-python-sklearn-kera/
|
70
translated/tech/20181003 Introducing Swift on Fedora.md
Normal file
70
translated/tech/20181003 Introducing Swift on Fedora.md
Normal file
@ -0,0 +1,70 @@
|
||||
介绍 Fedora上的 Swift
|
||||
======
|
||||
|
||||

|
||||
|
||||
Swift 是一种使用现代方法构建安全性、性能和软件设计模式的通用编程语言。它旨在成为各种编程项目的最佳语言,从系统编程到桌面应用程序,以及扩展到云服务。阅读更多关于它的内容以及如何在 Fedora 中尝试它。
|
||||
|
||||
### 安全、快速、富有表现力
|
||||
|
||||
与许多现代编程语言一样,Swift 被设计为比基于 C 的语言更安全。例如,变量总是在可以使用之前初始化。检查数组和整数是否溢出。内存自动管理。
|
||||
|
||||
Swift 将意图放在语法中。要声明变量,请使用 var 关键字。要声明常量,请使用 let。
|
||||
|
||||
Swift 还保证对象永远不会是 nil。实际上,尝试使用已知为 nil 的对象将导致编译时错误。当使用 nil 值时,它支持一种称为 **optional** 的机制。optional 可能包含 nil,但使用 **?** 运算符可以安全地解包。
|
||||
|
||||
一些额外的功能包括:
|
||||
|
||||
* 与函数指针统一的闭包
|
||||
* 元组和多个返回值
|
||||
* 泛型
|
||||
* 对范围或集合进行快速而简洁的迭代
|
||||
* 支持方法、扩展和协议的结构体
|
||||
* 函数式编程模式,例如 map 和 filter
|
||||
* 内置强大的错误处理
|
||||
* 拥有 do、guard、defer 和 repeat 关键字的高级控制流
|
||||
|
||||
|
||||
|
||||
### 尝试 Swift
|
||||
|
||||
Swift 在 Fedora 28 中可用,包名为 **swift-lang**。安装完成后,运行 swift 并启动 REPL 控制台。
|
||||
|
||||
```
|
||||
$ swift
|
||||
Welcome to Swift version 4.2 (swift-4.2-RELEASE). Type :help for assistance.
|
||||
1> let greeting="Hello world!"
|
||||
greeting: String = "Hello world!"
|
||||
2> print(greeting)
|
||||
Hello world!
|
||||
3> greeting = "Hello universe!"
|
||||
error: repl.swift:3:10: error: cannot assign to value: 'greeting' is a 'let' constant
|
||||
greeting = "Hello universe!"
|
||||
~~~~~~~~ ^
|
||||
|
||||
|
||||
3>
|
||||
|
||||
```
|
||||
|
||||
Swift 有一个不断发展的社区,特别底,有一个[工作组][1]致力于使其成为一种高效且有力的服务器端编程语言。请访问[主页][2]了解更多参与方式。
|
||||
|
||||
图片由 [Uillian Vargas][3] 发布在 [Unsplash][4] 上。
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://fedoramagazine.org/introducing-swift-fedora/
|
||||
|
||||
作者:[Link Dupont][a]
|
||||
选题:[lujun9972](https://github.com/lujun9972)
|
||||
译者:[geekpi](https://github.com/geekpi)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://fedoramagazine.org/author/linkdupont/
|
||||
[1]: https://swift.org/server/
|
||||
[2]: http://swift.org
|
||||
[3]: https://unsplash.com/photos/7oJpVR1inGk?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText
|
||||
[4]: https://unsplash.com/search/photos/fast?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText
|
Loading…
Reference in New Issue
Block a user