def draw_SOM (self,srch_str, dist_neu_searchq, neuron_labels,map_path): TOOLS = "pan,wheel_zoom,box_zoom,hover,resize" plot = figure(title=srch_str,title_text_font_size='20pt',tools=TOOLS,plot_width=1000,plot_height=1000) nid = sorted(dist_neu_searchq) dist = [dist_neu_searchq[n] for n in nid] norm_dist = [round((x-min(dist))*255/(max(dist)-min(dist))) for x in dist] # Light is might node_pos = utilities.generate_positions(self._map_dimensions) xx = [sub[0]for sub in node_pos] yy = [sub[1]for sub in node_pos] colours=["#%02x%02x%02x" % (g,0,g) for g in norm_dist] source = ColumnDataSource( data=dict( x=xx, y=yy, nid=nid, colors=colours, labels = neuron_labels ) ) plot.circle(xx,yy,source=source,size=50,fill_color=colours,fill_alpha=0.7,line_color=None) plot.text(xx, yy, text=norm_dist, alpha=0.5, text_font_size="15pt",text_baseline="middle", text_align="center") hover = plot.select(dict(type=HoverTool)) hover.tooltips = [ ("index", "@nid"), ("labels", "@labels") ] output_file(map_path) show(plot)
def __init__(self, map_dimensions=[15,15], weight_dimensions=200): self._map_dimensions = map_dimensions self._weight_dimensions = weight_dimensions self._neurons = [] self._neu_index= {} self._glomat = {} # Initializing neurons with random weights: logger.info('Beginning init of neurons in map') for idx, position in enumerate(utilities.generate_positions(map_dimensions)): random_wt=[random.random()*10 for i in range(weight_dimensions)] self._neurons.append(Neuron(id=idx, position=position, weights=random_wt)) self._neu_index.update({idx:self._neurons[-1]}) logger.info('Map neurons initialized')
def __init__(self, map_dimensions=[15, 15], weight_dimensions=200): self._map_dimensions = map_dimensions self._weight_dimensions = weight_dimensions self._neurons = [] self._neu_index = {} self._glomat = {} # Initializing neurons with random weights: logger.info('Beginning init of neurons in map') for idx, position in enumerate( utilities.generate_positions(map_dimensions)): random_wt = [ random.random() * 10 for i in range(weight_dimensions) ] self._neurons.append( Neuron(id=idx, position=position, weights=random_wt)) self._neu_index.update({idx: self._neurons[-1]}) logger.info('Map neurons initialized')
def draw_SOM(self, srch_str, dist_neu_searchq, neuron_labels, map_path): TOOLS = "pan,wheel_zoom,box_zoom,hover,resize" plot = figure(title=srch_str, title_text_font_size='20pt', tools=TOOLS, plot_width=1000, plot_height=1000) nid = sorted(dist_neu_searchq) dist = [dist_neu_searchq[n] for n in nid] norm_dist = [ round((x - min(dist)) * 255 / (max(dist) - min(dist))) for x in dist ] # Light is might node_pos = utilities.generate_positions(self._map_dimensions) xx = [sub[0] for sub in node_pos] yy = [sub[1] for sub in node_pos] colours = ["#%02x%02x%02x" % (g, 0, g) for g in norm_dist] source = ColumnDataSource(data=dict( x=xx, y=yy, nid=nid, colors=colours, labels=neuron_labels)) plot.circle(xx, yy, source=source, size=50, fill_color=colours, fill_alpha=0.7, line_color=None) plot.text(xx, yy, text=norm_dist, alpha=0.5, text_font_size="15pt", text_baseline="middle", text_align="center") hover = plot.select(dict(type=HoverTool)) hover.tooltips = [("index", "@nid"), ("labels", "@labels")] output_file(map_path) show(plot)