# -*- coding: utf-8 -*- """ Created on Thu Mar 16 14:52:58 2017 @author: Jarvis """ import tensorflow as tf import numpy as np import pandas as pd import math import random from pandas import Series,DataFrame def cal_dis(a,b)
Python进行KMeans聚类是比较简单的,首先需要import numpy,从sklearn.cluster中import KMeans模块: import numpy as np from sklearn.cluster import KMeans 然后读取txt文件,获取相应的数据并转换成numpy array: X = [] f = open('rktj4.txt') for v in f: regex = re.compile('\s+') X.append([float(regex