Skip to content

Instantly share code, notes, and snippets.

@curious-attempt-bunny
curious-attempt-bunny / python machine learning recipes.md
Last active October 17, 2017 18:16
python machine learning recipes

Common Patterns

Imports

import seaborn as sns
import matplotlib.pyplot as plt
%matplotlib inline
# Compare Classifiers
from matplotlib import pyplot
from sklearn.model_selection import KFold
from sklearn.model_selection import cross_val_score
from sklearn.linear_model import LogisticRegression
from sklearn.tree import DecisionTreeClassifier
from sklearn.neighbors import KNeighborsClassifier
from sklearn.discriminant_analysis import LinearDiscriminantAnalysis
from sklearn.naive_bayes import GaussianNB
from sklearn.svm import SVC
@curious-attempt-bunny
curious-attempt-bunny / clojure.md
Last active August 29, 2015 14:19
Setting up with Clojure
  • Download the Java agent from your New Relic account page - i.e. https://rpm.newrelic.com/accounts/:account_id.
  • Extract the zip to your app's directory.
  • Optionally change app_name in the newrelic/newrelic.yml configuration.
  • Download the Clojure incubator jar.
  • Create a newrelic/extensions directory in your app's directory.
  • Move the Clojure incubator jar there.
  • Add this to the project.clj: [details]
  :profiles {:dev {:jvm-opts [ "-Dextensions.dir=<path to app>/newrelic/extensions"
 "-javaagent:/newrelic/newrelic.jar"]}}
@curious-attempt-bunny
curious-attempt-bunny / game-data.txt
Created March 17, 2015 04:59
Viewer bug: Uncaught TypeError: Cannot read property 'replace' of undefined
5 8 10 13 17 23 27 30 38 41 48 54 57
map 1;neutral;2 2;neutral;2 3;neutral;2 4;neutral;2 5;neutral;2 6;neutral;2 7;neutral;2 8;player1;2 9;neutral;2 10;player2;2 11;neutral;2 12;neutral;6 13;neutral;2 14;neutral;2 15;neutral;2 16;neutral;2 17;neutral;2 18;neutral;2 19;neutral;2 20;neutral;6 21;neutral;2 22;neutral;2 23;neutral;2 24;neutral;6 25;neutral;6 26;neutral;2 27;player2;2 28;neutral;2 29;neutral;2 30;player1;2 31;neutral;6 32;neutral;2 33;neutral;2 34;neutral;2 35;neutral;2 36;neutral;2 37;neutral;2 38;player2;2 39;neutral;2 40;neutral;2 41;player1;2 42;neutral;2 43;neutral;2 44;neutral;2 45;neutral;2 46;neutral;2 47;neutral;2 48;player1;2 49;neutral;2 50;neutral;2 51;neutral;2 52;neutral;2 53;neutral;2 54;player2;2 55;neutral;2 56;neutral;2 57;neutral;2 58;neutral;6 59;neutral;2
round 0
player1 place_armies 41 2
map 1;neutral;2 2;neutral;2 3;neutral;2 4;neutral;2 5;neutral;2 6;neutral;2 7;neutral;2 8;player1;2 9;neutral;2 10;player2;2 11;neutral;2 12;neutral;6 13;neutral;2 14;neutral;2 15;neutral;2 1
d888
d8888
888
888
888
888
888
8888888
The exercise
Print numbers using the ascii art font below:
d888 .d8888b. .d8888b. d8888 888888888 .d8888b. 8888888888 .d8888b. .d8888b. .d8888b.
d8888 d88P Y88bd88P Y88b d8P888 888 d88P Y88b d88Pd88P Y88bd88P Y88bd88P Y88b
888 888 .d88P d8P 888 888 888 d88P Y88b. d88P888 888888 888
888 .d88P 8888" d8P 888 8888888b. 888d888b. d88P "Y88888" Y88b. d888888 888
888 .od888P" "Y8b. d88 888 "Y88b888P "Y88b 88888888 .d8P""Y8b. "Y888P888888 888
888 d88P" 888 888 8888888888 888888 888 d88P 888 888 888888 888
888 888" Y88b d88P 888 Y88b d88PY88b d88P d88P Y88b d88PY88b d88PY88b d88P
require 'rubygems'
require 'open-uri'
require 'hpricot'
require 'curb'
require 'json'
host = 'techlandia.herokuapp.com'
# host = 'localhost:3000'
url = "http://#{host}/posts.json"
cdataRegex = /<!\[CDATA\[(.*)\]\]>/m