本文整理匯總了Python中pyspark.ml.clustering.KMeans.explainParams方法的典型用法代碼示例。如果您正苦於以下問題:Python KMeans.explainParams方法的具體用法?Python KMeans.explainParams怎麽用?Python KMeans.explainParams使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pyspark.ml.clustering.KMeans
的用法示例。
在下文中一共展示了KMeans.explainParams方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: KMeans
# 需要導入模塊: from pyspark.ml.clustering import KMeans [as 別名]
# 或者: from pyspark.ml.clustering.KMeans import explainParams [as 別名]
sales = va.transform(spark.read.format("csv")
.option("header", "true")
.option("inferSchema", "true")
.load("/data/retail-data/by-day/*.csv")
.limit(50)
.coalesce(1)
.where("Description IS NOT NULL"))
sales.cache()
# COMMAND ----------
from pyspark.ml.clustering import KMeans
km = KMeans().setK(5)
print km.explainParams()
kmModel = km.fit(sales)
# COMMAND ----------
summary = kmModel.summary
print summary.clusterSizes # number of points
kmModel.computeCost(sales)
centers = kmModel.clusterCenters()
print("Cluster Centers: ")
for center in centers:
print(center)
# COMMAND ----------
開發者ID:yehonatc,項目名稱:Spark-The-Definitive-Guide,代碼行數:33,代碼來源:Advanced_Analytics_and_Machine_Learning-Chapter_29_Unsupervised_Learning.py
示例2: MlKMeans
# 需要導入模塊: from pyspark.ml.clustering import KMeans [as 別名]
# 或者: from pyspark.ml.clustering.KMeans import explainParams [as 別名]
# In[62]:
from pyspark.ml.clustering import KMeans as MlKMeans
firstMlKMeans = MlKMeans(
featuresCol="features", predictionCol="prediction", k=2,
initMode="k-means||", maxIter=20)
type(firstMlKMeans)
# `pyspark.ml` paketo modelių klasės turi `explainParams` metodą, kuruo išvedami modelio parametrų paaiškinimai.
# In[63]:
print(firstMlKMeans.explainParams())
# Apmokykime modelį.
# In[64]:
firstMlModel = firstMlKMeans.fit(ca1mlFeaturizedDF)
type(firstMlModel)
# In[65]:
firstMlModel.clusterCenters()