#1#
目前有各种语言都适合机器学习的开发,我选用了Python语言,主要有以下几个原因:
1,方便调试的解释型语言;2,跨平台执行作业;3,广泛的应用程序接口;4,丰富完善的开源工具包
#2#
必须的编程库
①Numpy&Scipy提供高级的数学运算机制,具备非常高效的向量和矩阵运算功能。
②Matplotlib绘图工具包
③Scikit-learn封装了大量经典以及最新的机器学习模型
④Pandas数据处理分析工具包
⑤Anaconda集成工具包
⑥Tensorflow开源框架。谷歌出品,必属精品。功能极其强大,我主要用于人工智能,深度学习,机器学习领域。相类似的还有facebook的PyTorch,较前者易上手,未深入了解。
#3#
环境配置
详细的安装过程看官网即可
install tensorflow with anaconda
我的安装步骤是Anaconda->Tensorflow框架及各种库
安装好anaconda后可以通过
conda install sth
来方便快捷的安装工具库
或通过pip来安装,这里要谨慎注意使用的pip版本,如果是安装python3.X的支持库,就要用pip3了
pip install -U sth
原因是,我想同时配置python2.7和python3.6开发环境,所以安装了两个版本的Anaconda,通过修改环境变量路径来使用不同版本的Anaconda。
#4#
踩到的坑以及解决方法
①第一个遇到的问题由于科学上网引起的问题;本来配置的本地代理采用socks协议,而在用pip安装软件时,报错
requests.exceptions.InvalidSchema: Missing dependencies for SOCKS support. #3516
我google了一下,采用了许多解决方案,最后采用的解决方式是修改socks协议为http协议,果然奏效了。
该解决方案链接,还可能其他原因引起的解决方案附上stackoverflow的链接
②第二个坑是
conda install matplotlib -n name
where name is the name you previously gave to your python 3 anaconda env
在conda虚拟环境中安装编码库时要指明环境名字,多版本环境下若不指定名字可能出现各种错误,如我所遇到的各种情况。
#5#
自用及分享
Anaconda初始阶段常用命令:(比较简单,不做翻译)
Managing conda
Verify that conda is installed and running on your system by typing:
conda--version
Conda displays the number of the version that you have installed. You do not need to navigate to the Anaconda directory.
EXAMPLE: conda 4.4.9
NOTE: If you get an error message, make sure you closed and re-opened the Terminal window after installing, or do it now. Then verify that you are logged into the same user account that you used to install Anaconda or Miniconda.
Update conda to the current version. Type the following:
conda update conda
Conda compares versions and then displays what is available to install.
If a newer version of conda is available, type y to update:
Proceed ([y]/n)? y
TIP: We recommend that you always keep conda updated to the latest version.
Managing Environments
Create a new environment and install a package in it.
We will name the environment snowflakes and install the package BioPython. At the Anaconda Prompt or in your Terminal window, type the following:
conda create --name snowflakes biopython
指定pip和python版本
conda create --name tensorflow3 pip python=3.6
Conda checks to see what additional packages (“dependencies”) Biopython will need, and asks if you want to proceed:
Proceed ([y]/n)? y
Type “y” and press Enter to proceed.
To use, or “activate” the new environment, type the following:
Windows: activate snowflakes
Linux and macOS: source activate snowflakes
Now that you are in your snowflakes environment, any conda commands you type will go to that environment until you deactivate it.
To see a list of all your environments, type:
condainfo--envs
A list of environments appears, similar to the following:
condaenvironments:base/home/username/Anaconda3snowflakes*/home/username/Anaconda3/envs/snowflakes
TIP: The active environment is the one with an asterisk (*).
Change your current environment back to the default (base):
Windows: deactivate
Linux, macOS: source deactivate
TIP: When the environment is deactivated, its name is no longer shown in your prompt, and the asterisk (*) returns to base. To verify, you can repeat the conda info --envs command.
Managing Python
When you create a new environment, conda installs the same Python version you used when you downloaded and installed Anaconda. If you want to use a different version of Python, for example Python 3.5, simply create a new environment and specify the version of Python that you want.
Create a new environment named “snakes” that contains Python 3.5:
conda create --name snakes python=3.5
When conda asks if you want to proceed, type “y” and press Enter.
Activate the new environment:
Windows: activate snakes
Linux, macOS: source activate snakes
Verify that the snakes environment has been added and is active:
conda info --envs
Conda displays the list of all environments with an asterisk (*) after the name of the active environment:
# conda environments:#base/home/username/anaconda3snakes*/home/username/anaconda3/envs/snakessnowflakes/home/username/anaconda3/envs/snowflakes
The active environment is also displayed in front of your prompt in (parentheses) or [brackets] like this:
(snakes) $
Verify which version of Python is in your current environment:
python --version
Deactivate the snakes environment and return to base environment:
Windows: deactivate
Linux, macOS: source deactivate
Managing packages
In this section, you check which packages you have installed, check which are available and look for a specific package and install it.
To find a package you have already installed, first activate the environment you want to search. Look above for the commands to activate your snakes environment.
Check to see if a package you have not installed named “beautifulsoup4” is available from the Anaconda repository (must be connected to the Internet):
conda search beautifulsoup4
Conda displays a list of all packages with that name on the Anaconda repository, so we know it is available.
Install this package into the current environment:
conda install beautifulsoup4
Check to see if the newly installed program is in this environment:
conda list
More information
Full documentation— https://conda.io/docs/ .
Free community support— https://groups.google.com/a/anaconda.com/forum/#!forum/anaconda .
Paid support options— https://www.anaconda.com/support/ .
网友评论