Skip to content

Instantly share code, notes, and snippets.

View hopped's full-sized avatar

Dennis Hoppe hopped

View GitHub Profile
@hopped
hopped / tdd-example-part-2
Created July 9, 2014 18:44
Example code from the book Test-Driven Development By Example by Kent Beck
#!/usr/bin/env python
'''
TODO
1. Invoke tearDown even if the test method fails
2. Catch and report setUp errors
3. Create TestSuite from a TestCase class
'''
class TestCase(object):
def __init__(self, name):
@hopped
hopped / ml-with-dtree-credits.py
Last active March 4, 2016 14:18
Identifying risky bank loans using a decision tree classifier (Pandas, Scikit Learn)
# Download data set via:
# http://archive.ics.uci.edu/ml/datasets/Statlog+%28German+Credit+Data%29
import numpy as np
import pandas as pd
from sklearn import tree
from sklearn import preprocessing
from sklearn.metrics import accuracy_score
from sklearn.metrics import confusion_matrix
from sklearn_pandas import DataFrameMapper
@hopped
hopped / ml-with-c50-credits.R
Created May 19, 2014 09:40
Identifying risky bank loans using C5.0 with boosting and cost matrix
# Download data set via:
# http://archive.ics.uci.edu/ml/datasets/Statlog+%28German+Credit+Data%29
#
# Note, the example below uses the pre-processed data that is used in the book 'Machine Learning with R' by Brett Lantz
library(C50)
df <- read.csv("credit.csv", stringsAsFactors=TRUE)
set.seed(12345)
df_rand <- df[order(runif(1000)),]
@hopped
hopped / ml-with-nb-spam.py
Last active August 29, 2015 14:01
Filtering mobile spam messages with Naive Bayes (includes text mining transformations)
# Download data set via:
# http://archive.ics.uci.edu/ml/datasets/SMS+Spam+Collection
import numpy as np
import pandas as pd
import string
from nltk import word_tokenize
from nltk.stem.porter import PorterStemmer
@hopped
hopped / ml-with-nb-spam.R
Last active May 27, 2019 05:56
Filtering mobile spam messages with Naive Bayes (includes text mining transformations)
# Download data set via:
# http://archive.ics.uci.edu/ml/datasets/SMS+Spam+Collection
# import libraries
library(caret)
library(e1071)
library(tm)
library(SnowballC)
# read in the dataset