Skip to content

Instantly share code, notes, and snippets.

Chee Sing Lee cheesinglee

  • Corvallis, OR
Block or report user

Report or block cheesinglee

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
@cheesinglee
cheesinglee / logistic-iris.pmml
Created May 30, 2018
BigML logistic regression model for iris, PMML export
View logistic-iris.pmml
<?xml version="1.0" encoding="UTF-8"?><PMML xmlns="http://www.dmg.org/PMML-4_3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="4.3">
<Header description="Model kind: logistic">
<Application name="BigML"/>
</Header>
<DataDictionary>
<DataField name="sepal length" displayName="" optype="continuous" dataType="double">
<Extension name="BigML-Field_ID" value="000000"/>
</DataField>
<DataField name="sepal width" displayName="" optype="continuous" dataType="double">
<Extension name="BigML-Field_ID" value="000001"/>
View model_vs_logistic.py
#!/usr/bin/python
import functools
import numpy as np
from matplotlib import pyplot as pp
from matplotlib.collections import PolyCollection
from matplotlib.cm import get_cmap
from bigml.api import BigML
@cheesinglee
cheesinglee / README.md
Created Jun 13, 2016 — forked from ashenfad/README.md
Dynamic Scatterplot - Iris
View README.md

Dynamic scatterplot of the iris dataset.

Controls:

  • Left click to choose X-axis.
  • Right click to choose Y-axis.
  • Alt + right click to choose color axis.
  • Repeat click (left, right, or alt) for log scale.
  • Hover over a point to see all field values.
  • Click a multi-point (larger circle) to cycle through values.
@cheesinglee
cheesinglee / anscombe.py
Created Oct 5, 2015
Scripts for correlations blog post
View anscombe.py
#!/usr/bin/env python
from __future__ import print_function
from scipy.stats import pearsonr,spearmanr
"""
Edward Tufte uses this example from Anscombe to show 4 datasets of x
and y that have the same mean, standard deviation, and regression
line, but which are qualitatively different.
matplotlib fun for a rainy day
@cheesinglee
cheesinglee / output.txt
Last active Aug 29, 2015
Map-reduce Spearman's rho?
View output.txt
Number of map-reduce blocks on columns, and population size on rows [200,500,1000,5000,10000]
1 3 5 10 20 30 50
================================================================================
uncorrelated data
0.020074 0.067028 0.150469 0.112782 0.260606 0.485714 0.400000
-0.018003 -0.095463 -0.102538 0.050660 0.031538 0.358824 0.333333
-0.011529 -0.000860 -0.019766 -0.164176 -0.203649 -0.167781 -0.183459
-0.004745 -0.021326 -0.014286 -0.075185 -0.091779 -0.063402 -0.051401
0.005333 0.000626 0.007783 0.024034 -0.040481 -0.017537 -0.115995
View kiva-update.py
KIVA_SNAPSHOT_URL = 'http://s3.kiva.org/snapshots/kiva_ds_json.zip'
PRUNE_FIELDS = ['terms', 'payments', 'basket_amount', 'description', 'name',
'borrowers', 'translator', 'video', 'image',
'funded_date', 'paid_date', 'paid_amount', 'funded_amount',
'planned_expiration_date', 'bonus_credit_eligibility',
'partner_id']
KEYS = ['sector', 'use', 'posted_date', 'location.country',
'journal_totals.entries', 'activity',
'loan_amount', 'status', 'lender_count']
View kivapredict.js
// check if a loan ID is at the end of the url
var re = /lend\/(\d+)/ ;
var result = re.exec(window.location.href) ;
var predict_url = "" ;
var model = ""
var global = null ;
// get stored bigml auth parameters and build prediction url
chrome.storage.sync.get(['model','username','apikey'],function(items){
predict_url = "https://bigml.io/andromeda/prediction?username=" + items.username + ";api_key=" + items.apikey ;
View fetchmodel.js
function fetchModel(){
chrome.storage.sync.get({
username: "BigML Username",
apikey: "BigML API Key"
},
function(items){
var models_url = "https://bigml.io/andromeda/model?name=kiva-model;username=" + items.username + ";api_key=" + items.apikey ;
var xmlHttp = new XMLHttpRequest() ;
xmlHttp.open("GET",models_url,false) ;
xmlHttp.send(null) ;
View options.js
// Saves options to chrome.storage
function save_options() {
var username = document.getElementById('username').value;
var apikey = document.getElementById('apikey').value;
chrome.storage.sync.set({
username: username,
apikey: apikey
}, function() {
// Update status to let user know options were saved.
chrome.runtime.sendMessage({greeting:"fetchmodel"}) ;
View options.html
<!DOCTYPE html>
<html>
<head><title>Kiva Predictor Options</title></head>
<body>
<label>
BigML Username:
<input type="text" id="username">
</label>
<br>
<label>
You can’t perform that action at this time.