Python開發工具:Anaconda+Sublime
作者:白寧超
2016年12月23日21:24:51
摘要:隨着機器學習和深度學習的熱潮,各種圖書層出不窮。然而多數是基礎理論知識介紹,缺乏實現的深入理解。本系列文章是作者結合視頻學習和書籍基礎的筆記所得。本系列文章將采用理論結合實踐方式編寫。首先介紹機器學習和深度學習的范疇,然后介紹關於訓練集、測試集等介紹。接着分別介紹機器學習常用算法,分別是監督學習之分類(決策樹、臨近取樣、支持向量機、神經網絡算法)監督學習之回歸(線性回歸、非線性回歸)非監督學習(K-means聚類、Hierarchical聚類)。本文采用各個算法理論知識介紹,然后結合python具體實現源碼和案例分析的方式(本文原創編著,轉載注明出處:Python開發工具:Anaconda+Sublime(1))
目錄
- 【Machine Learning】Python開發工具:Anaconda+Sublime(1)
- 【Machine Learning】機器學習及其基礎概念簡介(2)
- 【Machine Learning】決策樹在商品購買力能力預測案例中的算法實現(3)
- 【Machine Learning】KNN算法虹膜圖片識別實戰(4)
1 Anaconda和Sublime配置
1 安裝Anaconda集成環境,Anaconda下載,安裝下一步一路安裝結束。(無需環境變量配置),配置完成后,查看是否成功。
2 打開cmd進入dos命令下,輸入conda list 查看集成的python包
3 如果想添加新的python包,打開Anaconda官網:https://anaconda.org/search進行查找,比如想找到機器學習工具包scikit-learn
4 可以將Anaconda集成到PyDev、Pycharm、Eclipse、VS等編譯環境即可,本文介紹集成到sublime中,首先進入官網下載sublime
5 直接進行下一步安裝,一路到底。成功后顯示:
6 安裝Package Control: https://packagecontrol.io/installation
7 復制6中標記紅色的文本內容(如下),然后右擊紅色小框,選擇Console,將代碼如下所示的放入文本框中,按Enter即可。
import urllib.request,os,hashlib; h = 'df21e130d211cfc94d9b0905775a7c0f' + '1e3d39e33b79698005270310898eea76'; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); by = urllib.request.urlopen( 'http://packagecontrol.io/' + pf.replace(' ', '%20')).read(); dh = hashlib.sha256(by).hexdigest(); print('Error validating download (got %s instead of %s), please try manual install' % (dh, h)) if dh != h else open(os.path.join( ipp, pf), 'wb' ).write(by)
解決方法:
Package Control.sublime-settings]修改方法:Preferences
> Package Settings
> Package Control
> Settings - User
"channels": [ "http://cst.stu.126.net/u/json/cms/channel_v3.json", //"https://packagecontrol.io/channel_v3.json", //"https://web.archive.org/web/20160103232808/https://packagecontrol.io/channel_v3.json", //"https://gist.githubusercontent.com/nick1m/660ed046a096dae0b0ab/raw/e6e9e23a0bb48b44537f61025fbc359f8d586eb4/channel_v3.json" ]
激活版本:Help
>Enter LICENSE
----- BEGIN LICENSE ----- sgbteam Single User License EA7E-1153259 8891CBB9 F1513E4F 1A3405C1 A865D53F 115F202E 7B91AB2D 0D2A40ED 352B269B 76E84F0B CD69BFC7 59F2DFEF E267328F 215652A3 E88F9D8F 4C38E3BA 5B2DAAE4 969624E7 DC9CD4D5 717FB40C 1B9738CF 20B3C4F1 E917B5B3 87C38D9C ACCE7DD8 5F7EF854 86B9743C FADC04AA FB0DA5C0 F913BE58 42FEA319 F954EFDD AE881E0B ------ END LICENSE ------
8 完成7步驟后,按ctrl+shift+p打開如下窗口,並點擊標紅處,然后對應插件的下載和安裝
9 下圖輸入框安裝如下插件:
ConvertToUTF8 :解決中文問題
Colorsublime - Themes:Colorsublime 的主題集合
SublimeREPL:Python運行
SideBarEnhancements:側欄增強功能
Alignment:自動對齊,ctrl+alt+a
Anaconda:python插件集合,禁用PEP8提示:Sublime > Preferences > Package Settings > Anaconda > Settings – User: {"anaconda_linting": false}
SublimeLinter-pep8
根據需要自行添加插件
10 主題配置:打開 Preferences > Settings (若報錯,注意下圖紅色標記內容color_scheme整行替換)
{ "auto_indent": true, "bold_folder_labels": true, "color_scheme": "Packages/Color Scheme - Default/Monokai.tmTheme", "draw_white_space": "all", "font_size": 20, "font_face": "Consolas", "highlight_line": true, "ignored_packages": [ ], "preview_on_click": false, "rulers": [ 100 ], "save_on_focus_lost": true, "scroll_past_end": true, "show_encoding": true, "show_full_path": true, "show_line_endings": true, "smart_indent": true, "tab_size": 4, "translate_tabs_to_spaces": true, "trim_automatic_white_space": true, "trim_trailing_white_space_on_save": true, "use_tab_stops": true, "word_wrap": true, "wrap_width": 80 }
11 自定義快捷鍵盤配置:打開Preferences > Key Bindings輸入如下代碼,F5運行程序,F6切換IDEL工具,ctrl+d自定義刪除行,其他快捷鍵是通用的,網上很多快捷鍵的資料,這里不贅述。
[ { "keys": ["f5"], "caption": "SublimeREPL: Python - RUN current file", "command": "run_existing_window_command", "args": { "id": "repl_python_run", "file": "config/Python/Main.sublime-menu" } }, { "keys": ["f6"], "caption": "SublimeREPL: Python", "command": "run_existing_window_command", "args": { "id": "repl_python", "file": "config/Python/Main.sublime-menu" } },{ "keys": ["ctrl+d"], "command":"run_macro_file", "args": {"file":"res://Packages/Default/Delete Line.sublime-macro"} } ]
12 分屏:ALT+shift+1單屏,ALT+shift+2左右分屏,ALT+shift+8上下分屏,

13 如果沒有自動提示,可以如下配置,打開Preferences >Package Settings >Anaconda >Setting Default輸入:Administrator改為你計算機的名字
"python_interpreter": "C:/Users/Administrator/Anaconda3/python.exe"
打開Preferences >Package Settings >Anaconda >Setting Users輸入:Administrator改為你計算機的名字
{ "python_interpreter":"C:/Users/Administrator/Anaconda3/python.exe", "suppress_word_completions":true, "suppress_explicit_completions":true, "complete_parameter":true, }
到此,完成全部配置工作
2 Anaconda
- Anaconda理論介紹
- Anaconda簡介及安裝教程
- Windows下Anaconda的安裝和簡單使用
- 官網anaconda配置教程
- ANACONDA DISTRIBUTION
- 簡單⾼效地進⾏科學計算 : Python和Anaconda
3 PHP+Sublime開發
官網下載:http://www.sublimetext.com/3
安裝基本控件包:https://packagecontrol.io/installation
Ctrl+Shift+P 打開Package Control來安裝插件:
ConvertToUTF8
Bracket Highlighter:括號補全
DocBlockr:文檔注釋
Emmet:自動生成html
SideBar Enhancements:邊欄
{ "keys": ["ctrl+shift+c"], "command": "copy_path" },
//chrome
{ "keys": ["f5"], "command": "side_bar_files_open_with",
"args": {
"paths": [],
"application": "C:\\Users\\Administrator\\AppData\\Local\\Google\\Chrome\\Application\\chrome.exe",
"extensions":".*"
}
}
Themr:主題
Javascript Completions:js檢查
SublimeCodeIntel:代碼補全
SublimeLinter:代碼檢查
Alignment:自動對齊
PHP代碼語法正確性驗證插件 SublimeLinter
SublimeLinter SublimeLinter-php
安裝完插件以后去配置一下插件相關配置,在 Sublime Text 3菜單打開:Preferences -> Package Setting -> SublimeLinter -> Setting User,把如下內容填充進去:
{ "user": { "debug": false, "delay": 0.25, "error_color": "D02000", "gutter_theme": "Packages/SublimeLinter/gutter-themes/Default/Default.gutter-theme", "gutter_theme_excludes": [], "lint_mode": "background", "linters": { "annotations": { "@disable": false, "args": [], "errors": [ "FIXME" ], "excludes": [], "warnings": [ "NOTE", "README", "TODO", "XXX", "@todo" ] }, "php": { "@disable": false, "args": [], "excludes": [] }, "summitlinter": { "@disable": false, "args": [], "excludes": [], "globals": "", "ignore": "channel", "limit": null, "only": "" } }, "mark_style": "outline", "no_column_highlights_line": false, "passive_warnings": false, "paths": { "linux": [], "osx": [], "windows": [ "C:\\wamp\\bin\\php\\php5.5.12" ] }, "python_paths": { "linux": [], "osx": [], "windows": [] }, "rc_search_limit": 3, "shell_timeout": 10, "show_errors_on_save": false, "show_marks_in_minimap": true, "sublimelinter": "save-only", "sublimelinter_executable_map": { "php": "C:\\wamp\\bin\\php\\php5.5.12\\php.exe" }, "syntax_map": { "html (django)": "html", "html (rails)": "html", "html 5": "html", "javascript (babel)": "javascript", "magicpython": "python", "php": "php", "python django": "python", "pythonimproved": "python" }, "warning_color": "DDB700", "wrap_find": true } }
主題配置:打開 Preferences > Settings
{ "auto_indent": true, "bold_folder_labels": true, "color_scheme": "Packages/Color Scheme - Default/Monokai.tmTheme", "draw_white_space": "all", "font_size": 15.0, "highlight_line": true, "ignored_packages": [ ], "preview_on_click": false, "rulers": [ 100 ], "save_on_focus_lost": true, "scroll_past_end": true, "show_encoding": true, "show_full_path": true, "show_line_endings": true, "smart_indent": true, "tab_size": 4, "translate_tabs_to_spaces": true, "trim_automatic_white_space": true, "trim_trailing_white_space_on_save": true, "use_tab_stops": true, "word_wrap": true, "wrap_width": 80 }
sublime配置php
1 下載並安裝WampServer集成環境
2 按win+R輸入sysdm.cpl打開系統屬性,配置環境變量C:\wamp\bin\php\php5.5.12
3 cmd命令窗體,輸入命令php -h查看是否會提示php的命令使用方法
4 創建php編譯系統,運行Sublime Text,選擇Tool——>Build System——>New Build System,在新彈出的窗體中,
把默認內容
({ "shell_cmd": "make"}替換成
{ "cmd": ["php", "$file"], "file_regex": "php$", "selector": "source.php" }
保存在默認的目錄下即可,注意修改文件名為 php.sublime-build 。
重啟sublime text,就可以用Ctrl+B來編譯.php文件了;
4 Sublime
- ublime安裝教程
- Sublime Text 全程指南
- sublime3快捷鍵
- sublime插件
- sublime20個強大插件
- 如何優雅地使用Sublime Text
- sublime插件官方網站
- sublime+anaconda