【问题标题】:how to save a scikit-learn k-means clustering model?如何保存 scikit-learn k-means 聚类模型?
【发布时间】:2021-01-19 02:28:35
【问题描述】:

目前 K-means CLustring 代码在一个方法中是这样写的:

def predict(image_path):
image = cv2.imread(image_path)
image = image.reshape((image.shape[0] * image.shape[1], 3))
clt = KMeans(n_clusters = 3,  random_state=2, n_jobs=1)
clt.fit(image)

如何将其保存到模型中,以便将其转换为 Core-ML 并在我的应用程序中使用?

【问题讨论】:

    标签: python machine-learning scikit-learn cluster-analysis coreml


    【解决方案1】:

    Core ML 目前不支持 K-means 聚类。

    您可以在Swift Algorithm Club 找到 K-means 的简单实现。

    【讨论】:

      【解决方案2】:

      保存:

      pickle.dump(clt, open("save.pkl", "wb"))

      加载:

      clt = pickle.load(open("save.pkl", "rb"))

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2013-10-12
        • 2017-10-02
        • 1970-01-01
        • 2017-04-06
        • 1970-01-01
        • 2015-04-11
        • 2018-01-29
        • 2012-06-29
        相关资源
        最近更新 更多