def check_boxes(envir): boxes = envir.boxes for box_i in boxes: for box_j in boxes: if (box_i != box_j): plot.plot_box([box_i, box_j]) box_coll = (box_i, box_j, box_i(box_j), box_j(box_i)) print("%s;%s;%d,%d" % box_coll)
if str(feat_val)[-3:] == "inf" or str(feat_val) == "nan" or (abs(feat_val)>18 and i==1) : print feat_val,label continue pool_feature.append(feat_val) #apply pooling operator here pool_feature = np.std(pool_feature) if label == -1: class_1_feature.append(pool_feature ) elif label == 1: class1_feature.append(pool_feature ) axis = [0, 110, min(min(class_1_feature),min(class1_feature))-1, max(max(class_1_feature),max(class1_feature))+1] print len(class_1_feature) print len(class1_feature) # plot_scatter(class_1_feature, "class-1-"+feat_id_to_name[i],axis) # plot_scatter(class1_feature, "class1-"+feat_id_to_name[i],axis) # # plot_histogram(class_1_feature, "class-1-"+feat_id_to_name[i]) # plot_histogram(class1_feature, "class1-"+feat_id_to_name[i]) data_to_plot = [class1_feature,class_1_feature] plot_box(data_to_plot, "std-"+feat_id_to_name[i],["class 1","class -1"]) # plot_xy_histogram(class1_feature,class_1_feature, feat_id_to_name[i],["class1-","class-1-"])
class_positive_feature.append(np.std(pool_feature)) else: class_neutral_feature.append(np.std(pool_feature)) result.append(np.std(pool_feature)) results.append(result) axis = [ 0, 100000, min(min(class_negative_feature), min(class_positive_feature)) - 1, max(max(class_negative_feature), max(class_positive_feature)) + 1 ] # plot_scatter(class_1_feature, "class-1-"+feat_id_to_name[i],axis) # plot_scatter(class1_feature, "class1-"+feat_id_to_name[i],axis) # # plot_histogram(class_1_feature, "class-1-"+feat_id_to_name[i]) # plot_histogram(class1_feature, "class1-"+feat_id_to_name[i]) data_to_plot = [ class_positive_feature, class_negative_feature, class_neutral_feature ] plot_box(data_to_plot, "OKAO", feature_mapping[i], ["class 1", "class -1", "class 0"]) #plot_xy_histogram(class1_feature, class_1_feature, feat_id_to_name[i], ["image/class1-", "image/class-1-"]) labels.append("OKAO-" + feature_mapping[i]) results = list(map(list, zip(*results))) results = [[]] + results results[0] = labels with open("output-OKAO.csv", "wb") as f: writer = csv.writer(f) writer.writerows(results)
if str(feat_val)[-3:] == "inf" or str(feat_val) == "nan" or ( abs(feat_val) > 18 and i == 1): print feat_val, label continue pool_feature.append(feat_val) if label == -1: class_1_feature.append(np.std(pool_feature)) elif label == 1: class1_feature.append(np.std(pool_feature)) axis = [ 0, 100000, min(min(class_1_feature), min(class1_feature)) - 1, max(max(class_1_feature), max(class1_feature)) + 1 ] print len(class_1_feature) print len(class1_feature) # plot_scatter(class_1_feature, "class-1-"+feat_id_to_name[i],axis) # plot_scatter(class1_feature, "class1-"+feat_id_to_name[i],axis) # # plot_histogram(class_1_feature, "class-1-"+feat_id_to_name[i]) # plot_histogram(class1_feature, "class1-"+feat_id_to_name[i]) data_to_plot = [class1_feature, class_1_feature] plot_box(data_to_plot, "ACOUSTIC", feat_id_to_name[i], ["class 1", "class -1"]) # plot_xy_histogram(class1_feature,class_1_feature, feat_id_to_name[i],["class1-","class-1-"])
# continue if label == -1: class_1_feature += feat_val elif label == 1: class1_feature += feat_val elif label == 0: class0_feature += feat_val anova += feat_val labels.append(label) #word cloud 2 # word_cloud(' '.join(class_1_feature), "class_-1") # word_cloud(' '.join(class1_feature), "class_1") print len(class1_feature), len( class_1_feature) #, "\n", class1_feature, "\n", class_1_feature print "Avg", sum(class1_feature) * 1.0 / len(class1_feature), sum( class_1_feature) * 1.0 / len(class_1_feature) print "Max", max(class1_feature), max(class_1_feature) print "index", class1_feature.index( max(class1_feature)), class_1_feature.index(max(class_1_feature)) print "Std", np.std(class1_feature), np.std(class_1_feature) data_to_plot = [class1_feature, class_1_feature, class0_feature] plot_box(data_to_plot, "std-elongation", ["class 1", "class -1", "class 0"]) # # plot_xy_histogram(class1_feature,class_1_feature, "std-elongation",["class1-","class-1-"]) print anova print labels