def get_events_for_view(self, top_right, bottom_left): self.cur.execute("SELECT DISTINCT * FROM Venues WHERE VenueLatitude < ? AND VenueLongitude < ? AND VenueLatitude > ? " "AND VenueLongitude > ?", (top_right["latitude"], top_right["longitude"], bottom_left["latitude"], bottom_left["longitude"])) venues_in_sight = self.cur.fetchall() events_instance = Event() for venue in venues_in_sight: self.cur.execute("SELECT * FROM Events WHERE VenueId = ?", (venue[0],)) events = self.cur.fetchall() events = events[0] #for event in events: self.cur.execute("SELECT * FROM Categories WHERE CategoryId = ?", (events[1],)) category = self.cur.fetchall() events_instance.add_event(events, venue, category) return events_instance
def run(self): self.event_instance = self.data_manager.get_events_for_view(self.top_right, self.bottom_left) train_and_test = self.divide_events_into_train_test() training_data_array = np.array(self.event_instance.get_train_list(train_and_test["training_labels"])) training_target_array = np.array(self.event_instance.get_target_list(train_and_test["training_labels"])) testing_array = np.array(self.event_instance.get_test_list(train_and_test["testing_labels"])) testing_target = np.array(self.event_instance.get_target_list(train_and_test["testing_labels"])) #knn = neighbors.KNeighborsClassifier(10) #knn.fit(training_data_array, training_target_array) #testing_target = knn.predict(testing_array) data_points = np.concatenate((training_data_array, testing_array)) targets = np.concatenate((training_target_array, testing_target)) knn = neighbors.KNeighborsClassifier(12) knn.fit(data_points, targets) targets = knn.predict(data_points) targets_map = list() target_index = 0 for target in np.unique(targets): targets_map.append((target, target_index, Event.get_category_color(target))) target_index += 1 result = [] result.append([[t, c] for (t, i, c) in targets_map]) dp = list() #df = file("datapoints.csv", "w") for i in range(len(data_points)): # df.write(str(data_points[i][0])+","+str(data_points[i][1])+","+str(targets_map[targets[i]][0])+"\n") index = [index for (t, index, c) in targets_map if t == targets[i]] dp.append([data_points[i][0], data_points[i][1], index[0]]) result.append(dp) return result
def setUp(self): self.event = Event( id=249792023, name="January Event", time=1527344911000, status="upcoming", rsvp_limit=40, waitlist_count=10, yes_rsvp_count=40, announced=True, event_url= "https://www.example.com/Stockholm-Roleplaying-Guild/events/249792023/", venue={"name": "STORG Clubhouse"}) self.member = Member(name="Dave", meetup_id=100001, slack_id="u19292") self.table = GameTable(number=1, title="Awesome Game", blurb="Long text goes here", max_players=4, players=["Dave", "John", "Jane"], gm="Doe", system="D&D") self.rsvp = Rsvp(venue="STORG Clubhouse", response="yes", answers=["My email is [email protected]"], member={ "member_id": 100001, "name": "Dave" })
def check_circle_event(self, i): if (i.e is not None) and (i.e.x != self.x0): i.e.valid = False i.e = None if (i.pprev is None) or (i.pnext is None): return flag, x, o = self.circle(i.pprev.p, i.p, i.pnext.p) if flag and (x > self.x0): i.e = Event(x, o, i) self.event.push(i.e)