Skip to content

Instantly share code, notes, and snippets.

using Newtonsoft.Json;
using RabbitMQ.Client;
using RabbitMQ.Client.Events;
using System;
namespace RabbitMQSample
{
class Program
{
static void Main(string[] args)
@dormantroot
dormantroot / gist:4471411
Created January 7, 2013 00:55
lr_multi_apply
def check_test_data(test_X, test_y, all_theta):
""" USAGE: This method applies the optimized model to the test data set, with the theta values found after optimizing the cost function.
PARAMETERS:
test_X: the test data set
test_y: the test set's true results
all_theta: coefficients/theta values
RETURN:
"""
def sigmoid(z):
""" USAGE:
Compute the sigmoid of each value of z (z can be a matrix, vector or scalar).
PARAMETERS:
z - Matrix, vector or scalar
RETURN:
The sigmoid value
"""
"""NOTE: The following a simple two class classifier example"""
"""From the Iris dataset, find setosa and versicolour Iris types."""
iris = datasets.load_iris()
X = iris.data
y = iris.target
setosa_y = np.where(y == 0)
versicolour_y = np.where(y ==1)
X_stacked = np.vstack((X[setosa_y], X[versicolour_y]))
34.62365962451697,78.0246928153624,0
30.28671076822607,43.89499752400101,0
35.84740876993872,72.90219802708364,0
60.18259938620976,86.30855209546826,1
79.0327360507101,75.3443764369103,1
45.08327747668339,56.3163717815305,0
61.10666453684766,96.51142588489624,1
75.02474556738889,46.55401354116538,1
76.09878670226257,87.42056971926803,1
84.43281996120035,43.53339331072109,1
@dormantroot
dormantroot / gist:4223554
Created December 6, 2012 10:32
Logistic Regression using SciPy (fmin_bfgs)
import sys
import pylab as pl
from mpl_toolkits.mplot3d import Axes3D
from sklearn import datasets
import matplotlib.pyplot as plt
import matplotlib as matplot
import numpy as np
from scipy.optimize import fmin_bfgs
from sklearn import linear_model