泡菜.load: importterror:没有名为k_means_的模块



我用pickle倾倒一个sklearn.cluster.KMeans对象,像这样:

kmeans = KMeans(n_clusters=7)
kmeans.fit(X)
pickle.dump(kmeans, open(model_fname, "w"), protocol=2)

但是,如果我尝试重新加载这个pickle文件:

if os.path.exists(model_fname):
    print "Loading existing model .."
    return pickle.load(open(model_fname, "rb"))

我:

  File "C:Python27libpickle.py", line 1130, in find_class
    __import__(module)
ImportError: No module named k_means_

如何加载这个文件?

我刚刚用joblib代替了pickle:

from sklearn.externals import joblib

相关内容

  • 没有找到相关文章