This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"all_fields": true, | |
"category": 0, | |
"cluster": null, | |
"cluster_status": true, | |
"code": 200, | |
"columns": 15, | |
"created": "2013-05-07T20:30:05.554000", | |
"credits": 3.790340423584, | |
"description": "", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
""" | |
Created on Thu Oct 3 12:24:41 2013 | |
@author: cheesinglee | |
""" | |
import praw | |
from csv import DictWriter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// check if a loan ID is at the end of the url | |
var re = /lend\/(\d+)/ ; | |
var result = re.exec(window.location.href) ; | |
if (result !== null){ | |
// individual loan page | |
var loan_id = result[1] ; | |
img = makeStatusIndicator(loan_id) ; | |
$("#lendFormWrapper").append(img) ; | |
}else{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"manifest_version": 2, | |
"name": "Kiva Predictor", | |
"description": "Predict the success of Kiva loans using BigML models", | |
"version": "0.1", | |
"content_scripts": [ | |
{ | |
"matches": ["http://www.kiva.org/lend*"], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function makeStatusIndicator(loan_id){ | |
// this function executes the Kiva API query for a particular loan id, feeds the result through | |
// the actionable model, and returns a green light or red light icon depending on the result. | |
// create DOM object for icon | |
var img = $('<img class="indicator">') ; | |
// Kiva API call | |
var url = "http://api.kivaws.org/v1/loans/" + loan_id + ".json" ; | |
$.get(url,function(data){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function predictStatus(fundedAmount, country, loanAmount, sector, fundedDateDayOfWeek, fundedDateDayOfMonth, fundedDateMonth, fundedDateYear) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head><title>Kiva Predictor Options</title></head> | |
<body> | |
<label> | |
BigML Username: | |
<input type="text" id="username"> | |
</label> | |
<br> | |
<label> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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"}) ; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) ; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 ; |
OlderNewer