2 Aralık 2016 Cuma

İç takı (infix), Son Takı (Postfix) ve Ön takı (Prefix) Gösterimi


Bilindiği üzere matematiksel  işlemlerde kullanılan matematiksel  ifadelerde operatörler (+ - gibi)  işlenenler (operands) ve bu işlemler arasında önceliklerin tayin edildiği  parantez gibi ifadeler vardır. Son takı  ve iç takı gibi gösterimler, herhangi bir matematiksel ifadeyi (A+2 gibi bir  ifadeyi) bilgisayarların kolaylıkla  işleyebileceği , işlem öncelikleri ve   parantez gibi durumlar olmadan basit ve yalın biçimde gösterimi  maksadıyla ortaya konmuştur. Son takı (postfix) gösterimi Ters Polonyalı Gösterimi (Reverse Polish Notation) olarak, İç takı (infix) gösterimi ise  Polonya Gösterimi (Polish Notation) olarak adlandırılır. Polonyalı  gösterimi Polonyalı mantıkçı ve bilimci Jan Łukasiewicz tarafından 1924  tarihinde icat etmiştir. 

İç Takı Gösterimi

İç takı gösterimi, matematiksel ifadelerin alışılageldiği biçimde gösterimidir. Örneğin, 

( 6 - 3) ^2 – 11

ifadesi iç takı gösterimi şeklinde bir gösterimdir.

Son Takı Gösterimi (Postfix )
Son takı gösterimi, operatörleri ifadenin sonuna eklendiği gösterimdir. Burada ( 6 - 3) ^2 – 11 ifadesini ele alalım:

Matematiksel olarak bilindiği gibi işlem önceliği açısından ilk olarak parantez içerisine daha sonra üs işlemi olan ^ ifadesine bakacağız.
İlk olarak 6-3 ifadesini son takı formuna çevirelim. Son takıya çevrilmiş olan matematiksel ifade {} ile gösterilmiştir.

{6 3 - } ^ 2 - 11
{6 3 - 2 ^ } - 11
{6 3 - 2 ^ 11 - }
6 3 - 2 ^ 11 -


Ön Takı Gösterimi (Prefix )
Ön takı gösteriminde operatörleri ifadenin başına eklendiği gösterimdir. Burada tekrar ( 6 - 3) ^2 – 11 ifadesini ele alalım:
İlk olarak 6-3 ifadesini son takı formuna çevirelim. Son takıya çevrilmiş olan matematiksel ifade {} ile gösterilmiştir.

{- 6 3 } ^ 2 - 11
{^ - 6 3 2 } - 11
{- ^ - 6 3 2 11}


31 Ekim 2016 Pazartesi

Connection to Oracle database in weka Api


  As we dig through the weka, it is clear that any machine learning process necessitate data. One of the main source of data is database. In this blog, we have been discussing about the establishing connection to Oracle database to weka java api.

  Oracle is the one of the greatest database vendor, and in our example, we are going to use it. It takes fair time for me to establish connection, and I have struggled with many errors. I have found solutions from www.stackoverflow.com. This document is a gathering of experiences in order for database connection.

1-) First of all, you should download weka.jar and odbc6.jar. First one is for weka api, and the second one is for Oracle JDBC.

2-) My java IDE is Eclipse. You should right click on the project and properties --> Java Build Path --> Libraries --> Add External JARS and select the weka.jar and  odbc6.jar.

  2.1) If you add ojdbc14.jar, you would get  “ORA-28040: No matching authentication protocol exception “ error.
  2.2) If you do not add any JDBC here, you would get “No suitable driver found for jdbc:oracle:thin:@localhost:1521:XE “ error. ,

3-) You should be in the weka.jar’s installation folder and go through weka\weka\experiment path. you should select 
DatabaseUtils.props.oracle file. Just delete .oracle extention, Hence file is transforms to DatabaseUtils.props file. Copy this file to your java application's src folder. 

  3-1) If you are getting "WEKA - JDBC Connection Exception"  article 3 will solve the problem. 

4-) The content of the DatabaseUtils.props shall as follows: 

# Database settings for Oracle 10g Express Edition
#
# General information on database access can be found here:
# http://weka.wikispaces.com/Databases
#
# url:     http://www.oracle.com/
# jdbc:    http://www.oracle.com/technology/software/tech/java/sqlj_jdbc/
# author:  Fracpete (fracpete at waikato dot ac dot nz)
# version: $Revision: 5835 $

# JDBC driver (comma-separated list)
jdbcDriver=oracle.jdbc.driver.OracleDriver

# database URL
jdbcURL=jdbc:oracle:thin:@localhost:1521/ORCL

# specific data types
#string,getString()= 0;         -->nominal
#boolean,getBoolean() = 1;  -->nominal
#double,getDouble() = 2;    -->numeric
#byte,getByte() = 3;        -->numeric
#short,getByte()= 4;        -->numeric
#int,getInteger() = 5;            -->numeric
#long,getLong() = 6;                -->numeric
#gloat,getFloat() = 7;            -->numeric
#date,getDate() = 8;                -->date
VARCHAR2=0
NUMBER=2
DOUBLE_PRECISION=2
TIMESTAMP=8

# other options
CREATE_INT=INTEGER
CREATE_STRING=VARCHAR2(4000)
CREATE_DOUBLE=NUMBER
CREATE_DATE=TIMESTAMP
DateFormat=yyyy-MM-dd HH:mm:ss
checkUpperCaseNames=true
checkForTable=true


The content in yellow is crucial. If the database located in localhost, it should be localhost.If you designate an IP adress there, you could get "The Network Adapter could not establish the connection when connecting with Oracle DB" error. The phrase ORCL is a tnsname, and it should be as is in tnsnames.ora file in oracle installation directory.
The seperator before ORCL should be "/" not ":", "ORA-12505, TNS:listener does not currently know of SID given in connect descriptor" error could be encountered otherwise.