Python KMeans聚类报错ImportError: [joblib] Attempting to do parallel computing without

求大神指导!
代码的最后一行:
model.fit(data_zs) #开始聚类
运行完之后会报错,提示如下:
ImportError: [joblib] Attempting to do parallel computing without protecting 
your import on a system that does not support forking. To use parallel-computing
 in a script, you must protect your main loop using "if __name__ == '__main__'". 
Please see the joblib documentation on Parallel for more information

----------------------------------------------------------------------------------------
#-*- coding: utf-8 -*-
#使用K-Means算法聚类消费行为特征数据

import numpy as np
import pandas as pd

#参数初始化
inputfile = 'd:/test/consumption_data.xls' #销量及其他属性数据
k = 3 #聚类的类别
threshold = 2 #离散点阈值
iteration = 500 #聚类最大循环次数
data = pd.read_excel(inputfile, index_col = 'Id') #读取数据
data_zs = 1.0*(data - data.mean())/data.std() #数据标准化

from sklearn.cluster import KMeans
model = KMeans(n_clusters = k, n_jobs = 4, max_iter = iteration) #分为k类,并发数4
model.fit(data_zs) #开始聚类

你可能感兴趣的:(Python KMeans聚类报错ImportError: [joblib] Attempting to do parallel computing without)