华为云AI开发平台ModelArtsk均值_云淘科技
概述
“K-均值”节点用于产生聚类模型,用户在使用时需要指定聚类个数。K-均值算法是基于距离的算法,将所有数据归类到其最邻近的中心。
输入
参数 |
子参数说明 |
参数说明 |
---|---|---|
inputs |
dataframe |
inputs为字典类型,dataframe为pyspark中的DataFrame类型对象 |
输出
spark pipeline类型的模型
参数说明
参数 |
子参数说明 |
参数说明 |
---|---|---|
b_use_default_encoder |
– |
是否使用默认编码,默认为True |
input_features_str |
– |
输入的列名以逗号分隔组成的字符串,例如: “column_a” “column_a,column_b” |
cluster_feature_vector_col |
– |
算子输入的特征向量列的列名,默认为”model_features” |
prediction_col |
– |
pyspark kmeans聚类器输出的预测列 |
k |
– |
聚类的个数,默认为2 |
init_mode |
– |
聚类采用的初始算法,random、k-means,默认为”random” |
init_steps |
– |
采用k-means|| 初始化模式的步数,默认为2 |
max_iter |
– |
最大迭代次数,默认为20 |
tol |
– |
迭代算法的收敛阈值,默认为1e-4 |
样例
inputs = { "dataframe": None # @input {"label":"dataframe","type":"DataFrame"} } params = { "inputs": inputs, "b_output_action": True, "b_use_default_encoder": True, # @param {"label": "b_use_default_encoder", "type": "boolean", "required": "true", "helpTip": ""} "outer_pipeline_stages": None, "input_features_str": "", # @param {"label": "input_features_str", "type": "string", "required": "false", "helpTip": ""} "cluster_feature_vector_col": "model_features", # @param {"label": "cluster_feature_vector_col", "type": "string", "required": "true", "helpTip": ""} "prediction_col": "prediction", # @param {"label": "prediction_col", "type": "string", "required": "true", "helpTip": ""} "k": 2, # @param {"label": "k", "type": "integer", "required": "true", "range": "(0,2147483647]", "helpTip": ""} "init_mode": "random", # @param {"label": "init_mode", "type": "string", "required": "true", "options": "random,k-means", "helpTip": ""} "init_steps": 2, # @param {"label": "init_steps", "type": "integer", "required": "true", "range": "(0,2147483647]", "helpTip": ""} "max_iter": 20, # @param {"label": "max_iter", "type": "integer", "required": "true", "range": "(0,2147483647]", "helpTip": ""} "tol": 1e-4 # @param {"label": "tol", "type": "number", "required": "true", "range": "(0.0,none)", "helpTip": ""} } kmeans____id___ = MLSKmeans(**params) kmeans____id___.run() # @output {"label":"pipeline_model","name":"kmeans____id___.get_outputs()['output_port_1']","type":"PipelineModel"}
父主题: 聚类
同意关联代理商云淘科技,购买华为云产品更优惠(QQ 78315851)
内容没看懂? 不太想学习?想快速解决? 有偿解决: 联系专家