Skip to content

Instantly share code, notes, and snippets.

decisionmechanics

Block or report user

Report or block decisionmechanics

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
View 881A_chapter_9.py
#!/usr/bin/env python3
# pip3 install requests
import requests
import pprint
res = requests.get("http://xkcd.com/info.0.json", timeout=10)
print(f"Status code: {res.status_code}")
@decisionmechanics
decisionmechanics / App.js
Created May 30, 2019
Export Highcharts as SVG using external button
View App.js
import React, { Component } from "react";
import "./App.css";
import Highcharts from "highcharts";
import HighchartsReact from "highcharts-react-official";
import HighchartsExporting from "highcharts/modules/exporting";
HighchartsExporting(Highcharts);
class App extends Component {
constructor(props) {
@decisionmechanics
decisionmechanics / postman_problem_fetch_test.txt
Created Mar 15, 2019
Node fetch for API that has a Postman problem
View postman_problem_fetch_test.txt
process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = 0;
const fetch = require("node-fetch");
("use strict");
const fetchData = async url => {
try {
const response = await fetch(url, {
method: "POST",
@decisionmechanics
decisionmechanics / controller.R
Created Feb 5, 2019
Controller for FPET/FPEM container
View controller.R
library(magrittr)
library(rjags)
library(R2jags)
library(fpemreporting)
do_one_country_run <- function(survey_data_file_path) {
survey_data <- readr::read_csv(survey_data_file_path)
division_numeric_code <- survey_data$division_numeric_code[1]
fpemmodeling::do_1country_run(
@decisionmechanics
decisionmechanics / recommendation_engine_example.R
Last active Jun 28, 2018
Create item-based recommendations using a co-occurrence matrix
View recommendation_engine_example.R
get_recommendation_ratings <- function(rating_file_path) {
# Read user ID, item ID, user preference CSV data
ratings <- read.csv(file = rating_file_path, header = FALSE, col.names = c('user', 'item', 'preference'))
# Create item co-occurrence matrix
co_occurrence_matrix <- crossprod(table(ratings[, c('user', 'item')]))
# Convert long format to wide format and replace NAs with 0s
user_ratings <- tidyr::spread(ratings, user, preference, fill = 0)
@decisionmechanics
decisionmechanics / spark_random_forest.R
Created Mar 21, 2017
Predicting wine quality using a random forest classifier in SparkR
View spark_random_forest.R
library(readr)
library(dplyr)
url <- "https://archive.ics.uci.edu/ml/machine-learning-databases/wine-quality/winequality-white.csv"
df <-
read_delim(url, delim = ";") %>%
dplyr::mutate(taste = as.factor(ifelse(quality < 6, "bad", ifelse(quality > 6, "good", "average")))) %>%
dplyr::select(-quality)
@decisionmechanics
decisionmechanics / app.R
Created Jul 13, 2016
2012 General Social Survey cross tabulation Shiny app demo
View app.R
library(shiny)
library(tigerstats)
ui <- fluidPage(
headerPanel("2012 General Social Survey cross tabulation"),
sidebarPanel(
selectInput("row", "Row variable", names(gss2012), selected = "polviews"),
selectInput("column", "Column variable", names(gss2012), selected = "sex")
),
mainPanel(
View gss2012-exploratory-analysis.Rmd
# 2012 General Social Survey analysis
This report contains a basic exploratory analysis of the 2012 General Social Survey data from the `tigerstats` package.
```{r include=FALSE}
library(tigerstats)
```
Survey response count by gender is
@decisionmechanics
decisionmechanics / RouteConfig.cs
Created Jul 1, 2016
Configuration for route localization in ASP.NET MVC app
View RouteConfig.cs
namespace RouteLocalizationDemo
{
using System.Collections.Generic;
using System.Web.Mvc;
using System.Web.Routing;
using RouteLocalization.Mvc;
using RouteLocalization.Mvc.Setup;
using Controllers;
@decisionmechanics
decisionmechanics / Program.cs
Last active Nov 13, 2017
Microsoft Cognitive Services Face and Emotion API demo
View Program.cs
namespace FaceRecognitionDemo
{
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Net;
using System.Threading.Tasks;
You can’t perform that action at this time.