Skip to content

Instantly share code, notes, and snippets.

Kory Becker primaryobjects

Block or report user

Report or block primaryobjects

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
primaryobjects / linear-regression.R
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)
primaryobjects /
Last active Jan 20, 2020
How to submit a project to Udacity in Windows with a Google or Facebook login.

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 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
primaryobjects /
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.
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 {<box>: <value>} dict with '.' value for empties.
primaryobjects / id3.R
Last active Dec 26, 2019
Decision Tree with ID3 in R, machine learning, information gain, entropy.
View id3.R
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))
primaryobjects / informationGain.R
Last active Dec 25, 2019
Information Gain and Entropy calculation for usage with building Decision Trees with machine learning, AI. Demo
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))
primaryobjects / montyHall.R
Last active Jan 26, 2020
Monty Hall Problem and probability, simulated in R, Bayes Nets, bayesian nets.
View montyHall.R
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.
primaryobjects /
Created Dec 18, 2019
A summary of weak supervision and Snorkel.

Weak Supervision

Programmatically label millions of data points. See also here.

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.

primaryobjects / includes.txt
Last active Jan 11, 2020
Isolation 3x3 with game tree generation and AI Minimax with Alpha-Beta Pruning algorithm.
View includes.txt
View index.css
.cell {
width: 50px;
height: 50px;
border: 1px solid black;
transition: background-color 0.25s;
.player {
font-size: 40px;
position: absolute;
primaryobjects / app.js
Last active Oct 18, 2019
Example 3x3 grid of clickable cells for game board, cells change color with alternating clicks to simulate player 1 and player 2 (isolation).
View app.js
$(function() {
class Cell extends React.Component {
You can’t perform that action at this time.