コード例 #1
0
	def numPassengersByDayOfWeek(self, network):
		flights = network.countTotalBookedPerFlight()
		day_names = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
		num_peeps = np.zeros(7)

		for key, val in flights.items():
			date = key[0]
			day = Utils.date2DayOfWeek(date)
			num_peeps[day_names.index(day)] += sum(val.values())

		fracs = [val / num_peeps.sum() for val in num_peeps]

		plt.pie(fracs, labels=day_names, autopct='%1.1f%%', colors=("b","g","r","y", "c", "w", "m"))
		plt.title('Total Number of Passengers by Day of Week')
		plt.show()
コード例 #2
0
	def numFlightsByDayOfWeek(self, network):
		flights = network.f.getUniqueFlights()
		day_names = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
		num_flights = np.zeros(7)

		for group, df in flights:
			date = group[0]
			day = Utils.date2DayOfWeek(date)
			num_flights[day_names.index(day)] += 1

		fracs = [flight / num_flights.sum() for flight in num_flights]
	
		plt.pie(fracs, labels=day_names, autopct='%1.1f%%', colors=("b","g","r","y", "c", "w", "m"))
		plt.title('Total Number of Flights by Day of Week')
		plt.show()
コード例 #3
0
def encodeDate(date, date_reduction):
    """
    args:
        date: In the form month/day/year i.e. "4/8/2014"
        date_reduction: -1 for one_hot and is_weekend
                        0 for is_weekend
                        1 for one_hot only

    returns:
        various encodings of date
    """
    day = Utils.date2DayOfWeek(date)
    one_hot_day = oneHotDay(day)
    is_weekend = [Utils.isWeekend(day)]
    
    if date_reduction == -1:
        return np.hstack((one_hot_day, is_weekend))
    
    elif date_reduction == 0:
        return is_weekend
    
    elif date_reduction == 1:
        return one_hot_day