from pkg_resources import require
require('numpy')
import numpy as np
require('matplotlib')
from matplotlib import pyplot as plt
import read_data as rd
from matplotlib import gridspec

fig = plt.figure()
gs = gridspec.GridSpec(2, 2)
##################################################################################################################################################
dataset1_77 = rd.data_read('../cppProcessing2.0/output_reports/11092015_grain_size/cs04r-sc-serv-77.diamond.ac.uk/grain_size_test.txt',2)           #3528 ~1e6
dataset2_77 = rd.data_read('../cppProcessing2.0/output_reports/09_09_2015_grain_size/cs04r-sc-serv-77.diamond.ac.uk/grain_size_test.txt',2)         #background
dataset3_77 = rd.data_read('../cppProcessing2.0/output_reports/11092015_grain_size_fine_small_grain/cs04r-sc-serv-77.diamond.ac.uk/grain_size_test.txt',2)      #small grain

grain_size77_1 = np.array(dataset1_77[0])
bandwidth77_1 = np.array(dataset1_77[1])
errbar77_1 = np.array(dataset1_77[2])

grain_size77_2 = np.array(dataset2_77[0])
bandwidth77_2 = np.array(dataset2_77[1])
errbar77_2 = np.array(dataset2_77[2])

grain_size77_3 = np.array(dataset3_77[0])
bandwidth77_3 = np.array(dataset3_77[1])
errbar77_3 = np.array(dataset3_77[2])

ax1 = fig.add_subplot(gs[0,:])
line1 = ax1.plot(grain_size77_2, bandwidth77_2, '-r')
ax3 = fig.add_subplot(gs[1,0])
line1 = ax3.plot(grain_size77_3, bandwidth77_3, '-r')
from pkg_resources import require

require("numpy")
import numpy as np

require("matplotlib")
from matplotlib import pyplot as plt
import read_data as rd

fig, ax = plt.subplots()

##################################################################################################################################################
dataset_77 = rd.data_read(
    "../cppProcessing2.0/output_reports/14092015_threads/cs04r-sc-serv-83.diamond.ac.uk/grain_size_test.txt", 0
)
# dataset1_77 = rd.data_read('../cppProcessing2.0/output_reports/13092015_threads/cs04r-sc-serv-77.diamond.ac.uk/grain_size_test.txt',0)

# dataset_77 = rd.combine_data(dataset_77, dataset1_77)

grain_size77 = np.array(dataset_77[0])
bandwidth77 = np.array(dataset_77[1])
errbar77 = np.array(dataset_77[2])

line1 = ax.plot(grain_size77, bandwidth77, "-b*")

upper77 = errbar77 + bandwidth77
lower77 = bandwidth77 - errbar77
# ax.errorbar(grain_size77, bandwidth77, yerr = [errbar77, errbar77], fmt='r^')
##################################################################################################################################################
dataset_83 = rd.data_read(
    "../cppProcessing2.0/output_reports/14092015_threads_large/cs04r-sc-serv-83.diamond.ac.uk/grain_size_test.txt", 0
예제 #3
0
        classCount[vote] += 1
    sortedClassCount = sorted(classCount.iteritems(),
                              key=operator.itemgetter(1),
                              reverse=True)
    return sortedClassCount[0][0]


def create_Tree(dataset, label):
    num = len(dataset)
    classList = [example[-1] for example in dataset]
    if classList.count(classList[0]) == len(classList):
        return classList[0]
    if len(dataset[0]) == 1:
        return majorityCnt(classList)
    root_feature = best_split_feature(dataset)
    root_label = label[root_feature]
    decision_tree = {root_label: {}}
    del (label[root_feature])
    root_val = [dataset[i][root_feature] for i in range(num)]
    unique_val = set(root_val)
    for val in unique_val:
        sublabels = label[:]
        decision_tree[root_label][val] = create_Tree(
            split_dataset(dataset, root_feature, val), sublabels)
    return decision_tree


if __name__ == '__main__':
    data, labels = data_read()
    createPlot(create_Tree(data, labels))