import copy
import math
import random
import time
import sys
import matplotlib.pyplot as plt
import matplotlib.animation as animation
import decimal
# 用于初始化隶属度矩阵U
global MAX
MAX = 10000.0
# 用于结束条件
global Epsilon
Epsilon = 0.00000001
def import_data_format_iris(file):
"""
格式化数据,前四列为data,最后一列为cluster_location
数据地址 http://archive.ics.uci.edu/ml/machine-learning-databases/iris/
"""
data = []
cluster_location =[]
with open(str(file), 'r') as f:
for line in f:
current = line.strip().split(",")
current_dummy = []
for j in range(0, len(current)-1):
current_dummy.append(float(current[j]))
j += 1
if current[j] == "Iris-setosa\n":
cluster_location.append(0)
elif current[j] == "Iris-versicolor\n":
cluster_location.append(1)
else:
cluster_location.append(2)