def plot(): plt.hist(sale_price) plt.title("sales price") plt.xlabel("Price") plt.ylabel("Frequency") plt.axvline(x = calculate_statistics()[0], linewidth=1, color='r', linestyle='dashed',label='Mean') plt.axvline(x = calculate_statistics()[1], linewidth=1, color='g', linestyle='dashed',label='Median') plt.axvline(x = calculate_statistics()[2], linewidth=1, color='y', linestyle='dashed',label='Mode') plt.show()
def plot(): plt.figure(figsize=(10, 6)) plt.hist(sale_price, bins=40) plt.axvline(calculate_statistics()[0], label='mean', color='Red') plt.axvline(calculate_statistics()[1], label='median', color='Green') plt.axvline(calculate_statistics()[2], label='mode', color='Yellow') plt.legend() plt.show() return
def plot(): mean,median,mode=calculate_statistics() plt.hist(sale_price) plt.axvline(x=mean,c='r') plt.axvline(x=median,c='y') plt.axvline(x=mode,c='g') plt.show()
def plot(): list_1 = calculate_statistics() plt.hist(sale_price) plt.axvline(list_1[0]) plt.axvline(list_1[1]) plt.axvline(list_1[2]) plt.show()
def plot(): me, md, mo = calculate_statistics() plt.hist(sale_price, bins=50) plt.axvline(x=me, color='r') plt.axvline(x=md, color='b') plt.axvline(x=mo, color='g') plt.show()
def plot(): plt.hist(sale_price, bins=70) mean.median.mode = calculate_statistics() plt.axvline(mean) plt.axvline(median) plt.axvline(mode) plt.show()
def plot(): t = calculate_statistics() sale_price.hist() plt.axvline(t[0], color='b', linestyle='solid', linewidth=2) plt.axvline(t[1], color='r', linestyle='dashed', linewidth=4) plt.axvline(t[2], color='1', linestyle='dotted', linewidth=2) plt.show()
def plot(): m,md,mo=calculate_statistics() plt.hist(sale_price) plt.axvline(x=m,label='mean',c='r') plt.axvline(x=md,label='median',c='g') plt.axvline(x=mo,label='mode',c='y') plt.show()
def plot(): sale_price.hist(bins=50) mean, median, mode = calculate_statistics() plt.axvline(x=mean, color='red') plt.axvline(x=median, color='black') plt.axvline(x=mode, color='yellow') plt.show()
def plot(): mean, median, mode = calculate_statistics() #sale_price.mean(), sale_price.median(), sale_price.mode()[0] plt.hist(sale_price) plt.axvline(x=mean, label='mean', color='r') plt.axvline(x=median, label='median', color='c') plt.axvline(x=mode, label='mode', color='b') plt.show()
def plot(): mean, median, mode = calculate_statistics() plt.hist(sale_price, color='green', alpha=0.5, bins=200) plt.axvline(x=mean, color='red', label='mean') plt.axvline(x=median, color='blue', label='median') plt.axvline(x=mode, color='yellow', label='mode') plt.legend() plt.show()
def plot(): mean, median, mode = calculate_statistics() #print(mean, median, mode) plt.hist(sale_price, bins=20) plt.axvline(mean, color='r') plt.axvline(median, color='g') plt.axvline(mode, color='y') plt.show()
def plot(): value = calculate_statistics() #print(value[0]) plt.hist(sale_price) plt.axvline(value[0]) plt.axvline(value[1]) plt.axvline(value[2]) plt.show()
def plot(): mean, median, mod = calculate_statistics() x = sale_price plt.hist(x, bins=100, color='c', edgecolor='k', alpha=0.65) plt.axvline(mean, color='k', linestyle='dashed', linewidth=1) plt.axvline(median, color='r', linestyle='dashed', linewidth=1) plt.axvline(mod, color='g', linestyle='dashed', linewidth=1) plt.show()
def plot(): mean, median, mode = calculate_statistics() plt.hist(sale_price, color='c') plt.axvline(mean, color='b', linestyle='dashed', linewidth=2) plt.axvline(median, color='b', linestyle='dashed', linewidth=2) plt.axvline(pd.Series(mode).values, color='b', linestyle='dashed', linewidth=2)
def plot(): sale_price = dataframe['SalePrice'] mean, median, mode = calculate_statistics() plt.hist(dataframe['SalePrice'], bins=20, color='c') x = sale_price.value_counts() d = np.asscalar(x[x.values == x.values.max()].index) plt.axvline(mean, color='b', linestyle='dashed', linewidth=2) plt.axvline(median, color='r', linestyle='dashed', linewidth=2) plt.axvline(d, color='g', linestyle='dashed', linewidth=2) plt.show()
def plot(): mean_sale, median_sale, mode_sale = calculate_statistics() #sales = [mean_sale, median_sale, mode_sale] plt.hist(sale_price, color="b") #plt.axvline((mean_sale, median_sale, mode_sale), color='r', linestyle='dashed', linewidth=2) plt.axvline(mean_sale, color='g', linestyle='dashed', linewidth=2) plt.axvline(median_sale, color='r', linestyle='dashed', linewidth=2) plt.axvline(mode_sale[0], color='c', linestyle='dashed', linewidth=2) #plt.axvline(sales[0], sales[1],sales[2]) plt.show()
def plot(): mean, median, mode = calculate_statistics() ax = sale_price.plot(kind='hist',grid=True, color='c') ax.set_xlabel("Sales Price") ax.axvline(mean, color='r', label='Mean', linestyle='--', lw='1.9') ax.axvline(median, color='g', label='Median', linestyle='--', lw='1.9') ax.axvline(mode, color='m', label='Mode', linestyle='--', lw='1.9') ax.legend() ax.set_title('Histogram of Sale Price with Mean, Median and Mode') plt.show()
def plot(): mean, median, mode = calculate_statistics() plt.figure(figsize=(10, 6)) plt.hist(sale_price, bins=40) plt.plot([mode] * 300, range(300), label='mode') plt.plot([median] * 300, range(300), label='median') plt.plot([mean] * 300, range(300), label='mean') plt.ylim(0, 250) plt.legend() plt.show()
def plot(): mean, median, mode = calculate_statistics() plt.axvline(mean, label="Mean", color='g') plt.axvline(median, label="Median", color='r') plt.axvline(mode, label="Mode", color="y") plt.legend() plt.show() return
def plot(): x=calculate_statistics() mean=x[0] median=x[1] mode=x[2] plt.hist(sale_price,color='c') plt.axvline(mean,linestyle='dashed',color='b',label='mean') plt.axvline(median,linestyle='dashed',color='r',label='median') plt.axvline(mode[0],linestyle='dashed',color='g',label='mode') plt.legend(loc='upper right') plt.show()
def plot(): a = calculate_statistics() Mean = a[0] Median = a[1] Mode = a[2] result = plt.hist(sale_price, color='y') #plt.axvline(sale_price.mean(), color='red', linestyle='dashed', linewidth=2) #plt.axvline(sale_price.median(), color='g', linestyle='dashed', linewidth=2) plt.axvline(Mean, color='r', linestyle='dashed', linewidth=2) plt.axvline(Median, color='g', linestyle='dashed', linewidth=2) plt.axvline(Mode, color='b', linestyle='dashed', linewidth=2) plt.show()
def plot(): mean, median, mode = calculate_statistics() plt.figure(figsize=(14, 4)) plt.subplot(131) plt.hist(sale_price) plt.title('Mean') plt.axvline(mean, color='b', linestyle='dashed', linewidth=2) plt.subplot(132) plt.hist(sale_price) plt.title('Median') plt.axvline(median, color='b', linestyle='dashed', linewidth=2) plt.subplot(133) plt.hist(sale_price) plt.title('Mode') plt.axvline(mode, color='b', linestyle='dashed', linewidth=2) plt.show()
def plot(): #Get the mean, median and mode from calculate_statistics function for saleprice for housing Iowa args = calculate_statistics() #figure(figsize=(1,1)) creates an inch-by-inch image, which will be 80-by-80 pixels unless you also give a different dpi argument. plt.figure(figsize=(10, 6)) #plot the histogram for sale_price {bins = range of values on x axis and y denotes the count of elements falling between those range} plt.hist(sale_price, bins=40) #plot the mean by value on x being mode/mean/median plotted 300 times while on y being plotted 0-299 times to get a straight line plt.plot([args[0]] * 300, range(300), label='mode') plt.plot([args[1]] * 300, range(300), label='median') plt.plot([args[2]] * 300, range(300), label='mean') #limit the length of y till 250 only plt.ylim(0, 250) #plot the lables as well defined in mean, median and mode plotting plt.legend() #finally show the histogram along with mean, median and mode plt.show
# %load q02_plot/build.py # Default Imports import pandas as pd import matplotlib.pyplot as plt from greyatomlib.descriptive_stats.q01_calculate_statistics.build import calculate_statistics plt.switch_backend('agg') dataframe = pd.read_csv('data/house_prices_multivariate.csv') sale_price = dataframe.loc[:, 'SalePrice'] # Draw the plot for the mean, median and mode for the dataset list_1 = calculate_statistics() def plot(): list_1 = calculate_statistics() plt.hist(sale_price) plt.axvline(list_1[0]) plt.axvline(list_1[1]) plt.axvline(list_1[2]) plt.show() #calculate_statistics() plot()
# Default Imports import pandas as pd import matplotlib.pyplot as plt plt.switch_backend('agg') from greyatomlib.descriptive_stats.q01_calculate_statistics.build import calculate_statistics dataframe = pd.read_csv('data/house_prices_multivariate.csv') sale_price = dataframe.loc[:, 'SalePrice'] mmm = calculate_statistics() mean = mmm[0] median = mmm[1] mode = mmm[2] # Draw the plot for the mean, median and mode for the dataset def plot(): plt.figure(figsize=(10, 6)) plt.hist(sale_price, bins=40) plt.plot([mode] * 300, range(300), label='mode') plt.plot([median] * 300, range(300), label='median') plt.plot([mean] * 300, range(300), label='mean') #plt.ylim(0, 250) plt.legend() plt.show()
# %load q02_plot/build.py # Default Imports import pandas as pd import matplotlib.pyplot as plt plt.switch_backend('agg') from greyatomlib.descriptive_stats.q01_calculate_statistics.build import calculate_statistics mean,median,mode=calculate_statistics() dataframe = pd.read_csv('data/house_prices_multivariate.csv') sale_price = dataframe.loc[:,'SalePrice'] # Draw the plot for the mean, median and mode for the dataset def plot(): plt.figure(figsize=(10, 6)) plt.hist(sale_price, bins=40) plt.plot([mode]*300, range(300), label='mode') plt.plot([median]*300, range(300), label='median') plt.plot([mean]*300, range(300), label='mean') plt.ylim(0, 250) plt.legend() return plt.show() plot()