Skip to main content

Posts

setting response header connection to close

After some really time consuming effort to try to set header connection to "close" with WebAPI, i finally resorted to  good old all powerful nodejs.

Using the code below and fire away. It is able to accept incoming request from any port. Done! :)


Recent posts

using panda to find value matching certain criteria.

Say you have the following dataframe read into panda.

Id | F1    | F2      | Class
0  | True | True   | 0
0  | True | True   | 1
0  | True | True   | 0
0  | True | True   | 1

To select all the class with value 0 in a data frame, you can use

data.loc[data['Class'] == 0]

Class column name is case sensitive. You won't get anything out of using data['class'].


Mule Http Client Request logging

Best piece of logging i found - literally no code modification. Just add the following code in your log4j configuration file and all your logs will be revealed. :)



<AsyncLogger name="org.mule.module.http.internal.HttpMessageLogger" level="DEBUG" />
<AsyncLogger name="com.ning.http" level="DEBUG" />

Getting started with Credit Card Detection using xgBoost

One fine day i came across this article. Curiously wanted to see if this works, i found a way to quickly setup your machine to run it using docker. Yeap you can setup and run it in 30 minutes time.

All you have to do is install docker and run the following command


docker pull continuumio/anaconda docker run -i -t continuumio/anaconda /bin/bash This install anaconda with python 2.7. Don't worry about this version. Its all good plus xgboost works only on this version.

Additional library you might need to install are

conda install -c bioconda xgboost=0.6a2

conda install pyqt=4
After that, just run python and you can run all the command given in the article. 

django serving static files

In order to serve static files, you need to configure settings.py.  In this example, say we are hosting our static files under a folder called 'static' (and app) with a filename called index.html.


TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': ['static', 'app'],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

And finally set your "urls.py" 
from django.conf.urls import url from django.views.generic.base import TemplateView
urlpatterns = [     #url(r'^$', views.index, name='index2…

Golang Revel Web Framework for Windows installation

This is a guide to help setup Revel GoLang webframework on Windows.

So first thing you gotta do is install, golang here.

Next up, goto Revel website and follow


go get github.com/revel/cmd/revel It will install to "C:\Users\DefaultUserFolder\go\bin". So please add this to your PATH manually instead of the installation folder which is C:\Go. 

When you run the command above, you most likely don't need to run :- go build or go install.

Time to go! :)

Running XGBoost with R Studio

Let's say we are trying to use xgboost to make prediction about our data and here is a sample data that we're going to be using :-





Some terminology before moving on. R uses the term label to say, this is our expected output when we're building our model. Yes, it is really confusing. A label to becomes final output of our predictions.



Basically what we're trying to find is relation between smoking and high sugar intake will lead to a person having disease.  These are fake data of course.  There are people who smokes and eat as much choc as they like,  they still look sharp. (not me tho)

First we will create these data using R. Code example shows we're loading some libraries and then create a data frame called  'a'. Next it convert 'a' into a data table 'd'.

require(xgboost) require(Matrix) require(data.table) if (!require('vcd')) install.packages('vcd') a = data.frame(id=c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17, 18, 19…