2014年3月25日 星期二

weka3.6 with LibSVM

Step 1: download LibSVM
https://github.com/cjlin1/libsvm

Step2: unzip the zip file libsvm-master.zip,
  and then find the libsvm.jar in /where you unzip/libsvm-master/java

Step3: copy libsvm.jar into your Weka folder
  ex: in my path is D:\Weka3-6\

Step4: set up the CLASSPATH in your environment or in RunWeka.ini
in your environment
  in Windows:
    In the Control Panel click on System (or right click on My Computer and select Properties) and then go       to the Advanced tab. There you will find a button called Environment Variables, click it.
    Enter the "CLASSPATH" for the variable and add this value "D:\Weka3-6\libsvm.jar" after ";" if you have     other values in CLASSPATH

  DOS command:
    set CLASSPATH=%CLASSPATH%;D:\Weka3-6\libsvm.jar;

  in Linux:
    export CLASSPATH=$CLASSPATH: where your libsvm.jar
    if i put it in /home/user
    export CLASSPATH=$CLASSPATH:/home/user/libsvm.jar

in RunWeka.ini:
  in Windows:
    open RunWeka.ini with any text editor, you can find
    cp=%CLASSPATH%; in the last line
    add your path of libsvm.jar after ";"

    cp=%CLASSPATH%;D:\Weka3-6\libsvm.jar
    or
    cp=%CLASSPATH%;./libsvm.jar


2014年2月26日 星期三

#define in C is expands textually

#include<stdio.h>
#define square(x) x*x
main() 
{
    int x = 2;
    printf("%d\n", square(x + 1));
    return 0;
}

The answer is 5 not 9, because the preprocessor expands it textually like below.

x * x = 2+1 * 2+1 = 2+(1*2)+1=2+2+1=5
That is not function. We can fix it as

#define square (x) (x)*(x) 
or
#define square (x) ((x)*(x)) 


Using Sparse ARFF files as the input of weka association rule

the format is as below test.arff

 @relation test
 @attribute a {y}
 @attribute b {y}
 @attribute c {y}
 @attribute d {y}
 @attribute e {y}
 @attribute f {y}
 @attribute g {y}
 @attribute h {y}

@data
{1 y,3 y,5 y}
{2 y,3 y,5 y}
{2 y,6 y}
{1 y,3 y,5 y}
{3 y,5 y,7 y}
{1 y,2 y,3 y}
{2 y,4 y,5 y}
{2 y,3 y,5 y}
{3 y,5 y,7 y}
{1 y,2 y}
{1 y,5 y,7 y}

2013年11月27日 星期三

python search path

current directory(sys.path)-->PYTHONPATH-->installation-dependent default path; on Unix, this is usually "/usr/local/lib/python".

How Human and Robot are different?

We humans draw effeortlessly on many different cognitive capabilities for any given task, and we pursue a seemingly infinite variety of tasks. When we have difficulties, we don't freeze up; we muddle through.
                                                                               --from JOHN E. LAIRD
                                                                                          THE SOAR COGNITIVE ARCHITECTURE

2013年11月26日 星期二

Install Qt creator in UBUNTU (Manual)

Because using apt-get to install QT is not the last version, I try to install it manually.

step 1: Download file
Download the last version of QT from http://qt-project.org/downloads
For example, i download Qt Online Installer for Linux 64-bit, and then go to the download folder,
find the file "qt-linux-opensource-1.4.0-2-x86_64-online.run".

step 2: Rename file
It's with a little long name. So i rename it as "qt.run" using the command
~$ mv qt-linux-opensource-1.4.0-2-x86_64-online.run qt.run

step 3: Change the access permissions
~$ chmod -x qt.run

step 4: Run the file
~$ sudo ./qt.run

you will see the install screen like below


the you can install it step by step.

2013年11月24日 星期日

compiling opencv with g++

There are two methods in compiling opencv with g++ without IDE

First is typing following command in command line directly

~$  g++ testcv.cpp -o testcv `pkg-config opencv --cflags --libs `

ps: ` place in the left of 1 on the keyboard, not ' in the left of Enter

 Second is to set a makefile as below:

testcv: testcv.cpp
g++  -o ${@} $<  `pkg-config opencv --cflags --libs `

and then type make in command line

~$ make

note:

keep the sequence of the command. put the `pkg-config opencv --cflags --libs ` after others.

If you make a command like

~$  g++  `pkg-config opencv --cflags --libs ` testcv.cpp -o testcv

there will be error

I don't know why...><
###########################################################################
opencv on qt creater ubuntu

set .pro

INCLUDEPATH += /usr/local/include

LIBS += `pkg-config opencv --libs`

If an error occur like this

"Cannot connect creator comm socket /tmp/qt_temp.S27961/stub-socket: No such file or directory"

go to "Run Settings" and then cancel "Run in terminal"