Skip to content

Instantly share code, notes, and snippets.

@byelipk
byelipk / application_route.js
Last active August 29, 2015 14:02
An example of a Bootstrap 3 modal in Ember.js stemming from the example at http://emberjs.com/guides/cookbook/user_interface_and_interaction/using_modal_dialogs/
App.ApplicationRoute = Ember.Route.extend({
actions: {
/*
modalName : The name of a template to render, e.g. 'foo.signinForm'
model : A string or object with the value of a model that will be used to create a new record from the store
*/
openModal: function(modalName, model) {
var model = this.store.createRecord(model),
controller = this.controllerFor(modalName);
@byelipk
byelipk / adding-autocomplete-token-test.js
Created December 9, 2014 16:58
An example async test helper to use while integration testing addings tags with a Select2 component in an ember application.
import Ember from 'ember';
import startApp from '../helpers/start-app';
import '../helpers/complete-group-form-part-two';
var App;
module('Acceptance: AddingAutocompleteToken', {
setup: function() {
App = startApp();
},
@byelipk
byelipk / autocomplete-search.js
Created December 9, 2014 22:09
An example async test helper to use while integration testing autocomplete search with a Select2 component in an ember application. This example assumes we are searching for users based on their username.
import Ember from 'ember';
// register custom helper
Ember.Test.registerAsyncHelper('autocompleteSearch', function(app, username) {
// In order for this to work we need to mimic typing
// a username into the input field.
// 1. Let the initial keydown event activate Select2
triggerEvent('input.select2-input', 'keydown');
@byelipk
byelipk / get-color-name.js
Last active August 18, 2016 15:39
Takes a hex code as input and returns the name of the color as determined by http://chir.ag/projects/name-that-color/. Runs from the command line. Requires Phantom JS
var page = require('webpage').create();
var system = require('system');
if (system.args.length === 1) {
console.log('Usage: path/to/get-color-name.js "#FA13CC"');
phantom.exit();
}
// NOTE
// Hex code must be 6 chars long with an optional
@byelipk
byelipk / .vimrc
Created September 21, 2016 18:28
.vimrc
" Leader
let mapleader = " "
set backspace=2 " Backspace deletes like most programs in insert mode
set nobackup
set nowritebackup
set noswapfile "http://robots.thoughtbot.com/post/18739402579/global-gitignore#comment-458413287
set history=50
set ruler " show the cursor position all the time
set showcmd " display incomplete commands
@byelipk
byelipk / build.sh
Last active March 9, 2017 22:02
Run this file to set up a fresh Ubuntu install ready for deep learning and computer vision
cd ~
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install build-essential cmake pkg-config git unzip libcurl3-dev
# Set up GPU support
# 1. Install CUDA: This is a set of drivers for your GPU that allows it to run a low-level programming language for parallel computing.
# 2. Install CuDNN: This is a library of highly optimized primitives for deep learning.
@byelipk
byelipk / 1-ml-exercises.md
Last active February 6, 2025 17:02
Machine learning questions and answers

Exercises

1) How would you define Machine Learning?

Machine learning is a way for computer programs to improve their performance on a task over time given more data.

2) Can you name 4 types of problems where it shines?

Machine learning algorithms have had good results on problems such has spam detection in email, cancer diagnosis, fraudulent credit card transactions, and automatically driving vehicles.

3) What is a labeled training set?

A labeled training set is a collection of data where one of the features of the data indicates the class the training example belongs to. A labeled training set is used in supervised learning algorithms.

@byelipk
byelipk / 2-ml-exercises.md
Last active October 15, 2024 20:25
Machine learning questions and answers

Exercises

1. What Linear Regression training algorithm can you use if you have a training set with millions of features?

You could use batch gradient descent, stochastic gradient descent, or mini-batch gradient descent. SGD and MBGD would work the best because neither of them need to load the entire dataset into memory in order to take 1 step of gradient descent. Batch would be ok with the caveat that you have enough memory to load all the data.

The normal equations method would not be a good choice because it is computationally inefficient. The main cause of the computational complexity comes from inverse operation on an (n x n) matrix.

O n2 . 4 to O n3

2. Suppose the features in your training set have very different scales: what algorithms might suffer from this, and how? What can you do about it?

@byelipk
byelipk / 9-ml-exercises.md
Last active April 22, 2022 05:18
Machine learning questions and answers

Excercises

1. What are the main benefits of creating a computation graph rather than directly executing the computations? What are the main drawbacks?

Deep Learning frameworks that generate computation graphs, like TensorFlow, have several things going for it.

For starters, computation graphs will compute the gradients automatically. This saves you from having to do lots of tedious calculus by hand.

Another huge plus is that they are optimized to run on your computer's GPU. If this wasn't the case you'd need to learn either CUDA or OPENCL and write lots of C++ by hand. Not an easy thing to do.

Exercises

1. Draw an ANN using the original artificial neurons that compute the XOR operation.

TODO: Upload photo of XOR network

2. Why is it generally preferable to use a Logistic Regression classifier rather than a classical Perceptron (ie. a single layer of Linear Threshold Units trained using the Perceptron training algorithm)? How can you tweak a Perceptron to make it equivalent to a Logistic Regression classifier?

A classical perceptron will only converge if the data is linearly seperable. It also cannot compute class probabilities. The logistic regression classifier is able to converge on non-linear data and outputs class probabilities.