<commit_before>---
layout: post
title: "Daily Challenges"
date: 2017-01-01
excerpt: "Getting Work Done"
tags: [challenge, R, examples, code]
comments: true
---



-------------------------------------------------------------------------------
# Day 1

This day I'm going to venture into an area I'm not so familiar with: generative models. Most of what I have been taught in machine learning has focused on typical discriminative models for learning. To me, I think generative models have so much more potential for really tapping into probability distributions and simulation capabilities of your data. I say this as I'm totally novice about it! Nevertheless, implementing naive bayes is not hard to do. What I wanted to see was how to show those conditional probabilities in the margin of the data. 

Today we use the iris data set that ships with R. 

For inspiration on how to set up the marginal plots, see http://www.statmethods.net/advgraphs/layout.html




~~~ r
library(e1071)  # naiveBayes
library(RColorBrewer) # brewer.pal



# foo
table_dnorm <- function(row, from, to, n = 101 ,...) 
{
    xseq <- seq(from, to, length.out = n)
    dnorm(xseq, row[1], row[2], ...)
}

# Plots the PDF from a Naive Bayes conditional probability table<commit_msg>Added overview for challenge post<commit_after>---
layout: post
title: "Daily Challenges"
date: 2017-01-01
excerpt: "Getting Work Done"
tags: [challenge, R, examples, code]
comments: true
---


The start of my Git Pages site began with doing some daily challenges to work on my coding skills. However, with taking up some more physical challenges (i.e., working out 2 or 3 times a day, training for a marathon, power lifting, etc.), that fell by the wayside. Now I'm reinventing this site using a new (and awesome!) theme I really like. However, I did not want to lose all of the content from that initial launch at the start of the year. Below, I migrated the R markdown files to their markdown results as best I could. If there is anything wrong, go ahead and let me know either in a comment or a bug fix on the site repo. Otherwise, enjoy!

-------------------------------------------------------------------------------
# Day 1

This day I'm going to venture into an area I'm not so familiar with: generative models. Most of what I have been taught in machine learning has focused on typical discriminative models for learning. To me, I think generative models have so much more potential for really tapping into probability distributions and simulation capabilities of your data. I say this as I'm totally novice about it! Nevertheless, implementing naive bayes is not hard to do. What I wanted to see was how to show those conditional probabilities in the margin of the data. 

Today we use the iris data set that ships with R. 

For inspiration on how to set up the marginal plots, see http://www.statmethods.net/advgraphs/layout.html




~~~ r
library(e1071)  # naiveBayes
library(RColorBrewer) # brewer.pal



# foo
table_dnorm <- function(row, from, to, n = 101 ,...) 
{
    xseq <- seq(from, to, length.out = n)
    dnorm(xseq, row[1], row[2], ...)
}

# Plots the PDF from a Naive Bayes conditional probability table
{'fraction_non_alphanumeric': 0.117425431711146, 'fraction_numerical': 0.011930926216640502, 'mean_word_length': 3.1216041397153944, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5649036', 'n_tokens_mistral': 907, 'n_tokens_neox': 813, 'n_words': 460}