def visualize(coin_results): num_heads = coin_results.count("head") num_tails = coin_results.count("tail") heads_percentage = num_heads / (num_heads + num_tails) tails_percentage = num_tails / (num_heads + num_tails) return elice_utils.visualize_boxplot( "Coin Flip: %d times" % (num_heads + num_tails), [heads_percentage, tails_percentage], ["heads (%)", "tails (%)"])
def visualize(coin_results): num_heads = coin_results.count("head") num_tails = coin_results.count("tail") heads_percentage = num_heads / (num_heads + num_tails) tails_percentage = num_tails / (num_heads + num_tails) return elice_utils.visualize_boxplot("Coin Flip: %d times" % (num_heads + num_tails), [heads_percentage, tails_percentage], ["heads (%)", "tails (%)"])
def main(): training1_sentences = read_text_data('./txt_sentoken/pos/') training2_sentences = read_text_data('./txt_sentoken/neg/') testing_sentence = input() alpha = 0.1 prob1 = 0.5 prob2 = 0.5 prob_pair = naive_bayes(training1_sentences, training2_sentences, testing_sentence, alpha, prob1, prob2) plot_title = testing_sentence if len(plot_title) > 50: plot_title = plot_title[:50] + "..." print(elice_utils.visualize_boxplot(plot_title, list(prob_pair), ['Positive', 'Negative']))
def main(): training1_sentences = read_text_data('./txt_sentoken/pos/') training2_sentences = read_text_data('./txt_sentoken/neg/') testing_sentence = input() alpha = 0.1 prob1 = 0.5 prob2 = 0.5 prob_pair = naive_bayes(training1_sentences, training2_sentences, testing_sentence, alpha, prob1, prob2) plot_title = testing_sentence if len(plot_title) > 50: plot_title = plot_title[:50] + "..." print( elice_utils.visualize_boxplot(plot_title, list(prob_pair), ['Positive', 'Negative']))