Python 有許多數據分析的套件,包含:
在 Azure Machine Learning 中,可以使用 Execute Python Script,透過 Rython 語言擴充功能,和 Execute R Script 的用法類似,直接將程式碼貼至 Python Script 區域就可以執行,下圖為預設的 Python 程式碼內容,若執行成功會看到 Execute Python Script 出現綠勾勾,若失敗則會顯示紅驚嘆號,失敗原因可以從屬性下方的 View output log 查看
新增 Iris Two Class Data 鳶尾花分類資料集
新增 Execute Python Script,將資料集輸出接至 Execute Python Script 的第一個輸入,Python Script 區域輸入以下 Python 語言:
# The script MUST contain a function named azureml_main
# which is the entry point for this module.
# imports up here can be used to
# The entry point function can contain up to two input arguments:
# Param<dataframe1>: a pandas.DataFrame
# Param<dataframe2>: a pandas.DataFrame
def azureml_main(dataframe1):
# Execution logic goes here
import matplotlib
matplotlib.use("agg")
from pandas.tools.plotting import scatter_matrix
import matplotlib.pyplot as plt
fig = plt.figure();
ax= fig.gca()
scatter_matrix(dataframe1,ax=ax)
# If a zip file is connected to the third input port is connected,
# it is unzipped under ".\Script Bundle". This directory is added
# to sys.path. Therefore, if your zip file contains a Python file
# mymodule.py you can import it using:
# import mymodule
# Return value must be of a sequence of pandas.DataFrame
fig.savefig("scatter.png")
return dataframe1,
執行完成後,滑鼠右鍵點選 Python Device 的 Visualize 檢視結果
可以看到以下所有欄位的散佈圖矩陣:
參考文章:在 Azure Machine Learning Studio 中執行 Python 機器學習服務指令碼