示例#1
0
    def test_normalize_equilateral(self):
        # find the Iris data set
        irisFile = os.path.dirname(os.path.realpath(__file__))
        irisFile = os.path.abspath(irisFile + "../../../datasets/iris.csv")

        norm = Normalize()
        result = norm.load_csv(irisFile)
        classes = norm.build_class_map(result, 4)
        norm.norm_col_equilateral(result, 4, classes, 0, 1)
        self.assertEqual(len(result[0]), 6)
        self.assertAlmostEqual(result[0][4], 0.06698, 3)
示例#2
0
iris_work = norm.load_csv(irisFile)

# Extract the original iris species so we can display during the final validation.
ideal_species = [row[4] for row in iris_work]

# Setup the first four fields to "range normalize" between -1 and 1.
for i in range(0, 4):
    norm.make_col_numeric(iris_work, i)
    norm.norm_col_range(iris_work, i, 0, 1)

# Discover all of the classes for column #4, the iris species.
classes = norm.build_class_map(iris_work, 4)
inv_classes = {v: k for k, v in classes.items()}

# Normalize iris species using equilateral
norm.norm_col_equilateral(iris_work, 4, classes, 0, 1)

# Display the resulting data
#norm.display_data(result)

training = np.array(iris_work)
training_input = training[:, 0:4]
training_ideal = training[:, 4:6]

# Create an RBF network.  There are four inputs and two outputs.
# There are also five RBF functions used internally.
# You can experiment with different numbers of internal RBF functions.
# However, the input and output must match the data set.
network = RbfNetwork(4, 5, 2)
network.reset()
示例#3
0
aifh_dir = os.path.dirname(os.path.abspath(__file__))
aifh_dir = os.path.abspath(aifh_dir + os.sep + ".." + os.sep + "lib" + os.sep + "aifh")
sys.path.append(aifh_dir)

from normalize import Normalize


# find the Iris data set
irisFile = os.path.dirname(os.path.realpath(__file__))
irisFile = os.path.abspath(irisFile + "../../datasets/iris.csv")

# Read the Iris data set.
print('Reading CSV file: ' + irisFile)
norm = Normalize()
result = norm.load_csv(irisFile)

# Setup the first four fields to "range normalize" between -1 and 1.
for i in range(0, 4):
    norm.make_col_numeric(result, i)
    norm.norm_col_range(result, i, -1, 1)

# Discover all of the classes for column #4, the iris species.
classes = norm.build_class_map(result, 4)

# Normalize iris species with equilateral encoding
norm.norm_col_equilateral(result, 4, classes, -1, 1)

# Display the resulting data
norm.display_data(result)

示例#4
0
# Find the AIFH core files
aifh_dir = os.path.dirname(os.path.abspath(__file__))
aifh_dir = os.path.abspath(aifh_dir + os.sep + ".." + os.sep + "lib" + os.sep +
                           "aifh")
sys.path.append(aifh_dir)

from normalize import Normalize

# find the Iris data set
irisFile = os.path.dirname(os.path.realpath(__file__))
irisFile = os.path.abspath(irisFile + "../../datasets/iris.csv")

# Read the Iris data set.
print('Reading CSV file: ' + irisFile)
norm = Normalize()
result = norm.load_csv(irisFile)

# Setup the first four fields to "range normalize" between -1 and 1.
for i in range(0, 4):
    norm.make_col_numeric(result, i)
    norm.norm_col_range(result, i, -1, 1)

# Discover all of the classes for column #4, the iris species.
classes = norm.build_class_map(result, 4)

# Normalize iris species with equilateral encoding
norm.norm_col_equilateral(result, 4, classes, -1, 1)

# Display the resulting data
norm.display_data(result)
示例#5
0
iris_work = norm.load_csv(irisFile)

# Extract the original iris species so we can display during the final validation.
ideal_species = [row[4] for row in iris_work]

# Setup the first four fields to "range normalize" between -1 and 1.
for i in range(0, 4):
    norm.make_col_numeric(iris_work, i)
    norm.norm_col_range(iris_work, i, 0, 1)

# Discover all of the classes for column #4, the iris species.
classes = norm.build_class_map(iris_work, 4)
inv_classes = {v: k for k, v in classes.items()}

# Normalize iris species using equilateral
norm.norm_col_equilateral(iris_work, 4, classes, 0, 1)


# Display the resulting data
#norm.display_data(result)

training = np.array(iris_work)
training_input = training[:, 0:4]
training_ideal = training[:, 4:6]

# Create an RBF network.  There are four inputs and two outputs.
# There are also five RBF functions used internally.
# You can experiment with different numbers of internal RBF functions.
# However, the input and output must match the data set.
network = RbfNetwork(4, 5, 2)
network.reset()