Instantly share code, notes, and snippets.

# Kory Beckerprimaryobjects

• Sort options
Created Jan 31, 2020
Linear regression with gradient descent in R.
View linear-regression.R
 # # An example of calculating linear regression with gradient descent for a single variable. # Kory Becker # 1/31/2020 # # Calculate linear regression with gradient descent. linearRegression <- function(x, y, alpha, iterations) { # initialize coefficients theta <- matrix(c(0,0), nrow=2)
Last active Jan 20, 2020
View udacity-submit.md

# How to submit a project to Udacity in Windows

When submitting a project to Udacity with a login on Google or Facebook, you will need to copy a `jwt` file to your PC in order for the login to work. Here's how.

1. Save the link https://project-assistant.udacity.com/auth_tokens/new to `C:\Users\YOUR_USER_NAME\AppData\Roaming\udacity-pa`
2. Open a CMD in Windows.
3. Navigate to your project source code folder:
`cd c:\projects\aind-sudoku`
Last active Jan 19, 2020
Sudoku puzzle convert string of values into a dictionary of key/value pairs. Udacity Artificial Intelligence nanodegree project 1, quiz 1: Encoding the Board.
View 1-sudoku-box.py
 from utils import * # `grid` is defined in the test code scope as the following: # (note: changing the value here will _not_ change the test code) # grid = '..3.2.6..9..3.5..1..18.64....81.29..7.......8..67.82....26.95..8..2.3..9..5.1.3..' def grid_values(grid): """Convert grid string into {: } dict with '.' value for empties. Args:
Last active Dec 26, 2019
Decision Tree with ID3 in R, machine learning, information gain, entropy.
View id3.R
 library(data.tree) entropy <- function(q) { # Calculate the entropy for a value. -1 * (q * log2(q) + (1 - q) * log2(1 - q)) } positiveRatio <- function(data, outcomeCol = ncol(data)) { # Calculate the ratio of T by the total samples. positiveCount <- length(which(data[, outcomeCol] == T))
Last active Dec 25, 2019
Information Gain and Entropy calculation for usage with building Decision Trees with machine learning, AI. Demo https://repl.it/repls/ParchedCompetentLegacysystem
View informationGain.R
 entropy <- function(q) { # Calculate the entropy for a value. -1 * (q * log2(q) + (1 - q) * log2(1 - q)) } positiveRatio <- function(data) { # Calculate the ratio of positives by the total measurements. sum(data\$positives) / (sum(data\$positives) + sum(data\$negatives)) }
Last active Jan 26, 2020
Monty Hall Problem and probability, simulated in R, Bayes Nets, bayesian nets.
View montyHall.R
 library(ggplot2) montyHall <- function(maxDoors = 3, switch = T, tries = 10) { plays <- data.frame() for (i in 1:tries) { # Create the doors. doors <- 1:maxDoors # Choose a winning door.
Created Dec 18, 2019
A summary of weak supervision and Snorkel.
View weak-supervision.md

# Weak Supervision

## How does it work?

Ask domain experts for weak supervision signals (heuristics) to use as labeling functions, which can be programatically implemented for automatic labeling.

Examples of labeling functions: regular expressions, dependency trees, knowledge bases, crowdsourcing.

Last active Jan 11, 2020
Isolation 3x3 with game tree generation and AI Minimax with Alpha-Beta Pruning algorithm. https://codepen.io/primaryobjects/pen/QWWGgmR
View includes.txt