Skip to content

Instantly share code, notes, and snippets.

@marks
Last active August 29, 2015 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marks/5c1c41df93b9cfa0f681 to your computer and use it in GitHub Desktop.
Save marks/5c1c41df93b9cfa0f681 to your computer and use it in GitHub Desktop.
Algorithmia algorithm for descriptive statistics on numeric columns of data

Algorithm URL: https://algorithmia.com/algorithms/marksskram/SocrataOpenDataAnalysis

INPUT: ["open.whitehouse.gov","rcp4-3y7g","select * order by salary desc limit 100"]

OUTPUT:

{
    "duration": 1.131406922,
    "result": {
        "querySettings": {
            "domain": "open.whitehouse.gov",
            "datasetFourByFour": "rcp4-3y7g",
            "queryString": "select * order by salary desc limit 5"
        },
        "queryResults": [
        	/* what you would expect */
        ],
        "numericColumns": [
            {
                "position": 3,
                "id": 134381418,
                "width": 142,
                "name": "Salary",
                "fieldName": "salary",
                "description": "The salary paid per period",
                "dataTypeName": "money",
                "renderTypeName": "money",
                "format": {},
                "fieldValues": [
                    179700,
                    179700,
                    172200,
                    172200,
                    172200
                ],
                "someStats": { /* powered by https://algorithmia.com/algorithms/marksskram/SomeStats alg */
                    "min": 172200,
                    "median": 172200,
                    "max": 179700,
                    "variance": 16875000,
                    "mean": 175200,
                    "sum": 876000,
                    "n": 5,
                    "standardDeviation": 4107.919181288746
                }
            }
        ]
    }
}

CURL it:

curl -X POST -d '["open.whitehouse.gov","rcp4-3y7g","select * order by salary desc limit 5"]' -H 'Content-Type: application/json' -H 'Accept: application/json' -H 'Authorization: YOUR_ALGORITHMIA_KEY_HERE' https://api.algorithmia.com/api/marksskram/SocrataOpenDataAnalysis/0.1.6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment