I'm new to Neural Networks so please be patient with me. I'm trying to replicate in Python a Probabilistic neural network from R. For replication purposes I'm using the well-known iris dataset from sklearn.datasets.
As you can see in the Python code below, I'm using the PNN provided by neupy. The estimated probabilities for the test set are printed in the end.
#import pandas, sklearn, numpy, neupy
data = datasets.load_iris()
df = pd.DataFrame(data['data']).assign(y=data['target'])
df_train = df.iloc[0:145,:]
df_test = df.iloc[145:,:] #test set consists of the last 5 observations
pnn = algorithms.PNN(std=0.5, verbose=True)
pnn.train(df_train.iloc[:,0:3], df_train.iloc[:,4])
pred_prob = pnn.predict_proba(df_test.iloc[:,0:3])
### Predicted probabilities ###
P(Y=0) P(Y=1) P(Y=2)
0.0000 0.2690 0.7310
0.0000 0.4082 0.5918
0.0000 0.2505 0.7495
0.0000 0.1083 0.8917
0.0000 0.3373 0.6627
However, if I do the same approach (or at least I think it's the same) in R on the same data set, I do not get the same results. In R I'm using the pnn-package. Here is what I'm doing in R:
#library('pnn')
Data <- read.table("iris.csv", sep=",", header=TRUE)
data.train <- data[1:145,]
data.test <- data[146:150,] # test set consists of the last 5 observations
nn <- smooth(learn(data.train, category.column = 5), sigma = .5)
x.train <- as.matrix(data.test[1:4])
pred <- apply(x.train, 1, function(x) guess(nn, c(x)))
### Predicted Probabilites ###
P(Y=0) P(Y=1) P(Y=2)
0.0000 0.1353 0.8647
0.0000 0.3683 0.6317
0.0000 0.2365 0.7635
0.0000 0.0972 0.9028
0.0000 0.3849 0.6151
Are there some parameters that I do not take into account? Or do the networks just work in different ways?