Skip to content

Commit

Permalink
Merge branch 'release/6.1.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
vigsterkr committed Dec 7, 2017
2 parents dad82b4 + 459b968 commit 94be17f
Show file tree
Hide file tree
Showing 40 changed files with 383 additions and 539 deletions.
14 changes: 14 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
2017-12-05 Viktor Gal <viktor.gal@shogun-toolbox.org>

* SHOGUN Release version 6.1.3 (libshogun 18.0, data 0.11, parameter 1)

* Features:
- Drop all <math.h> function calls [Viktor Gal]
- Use c++11 std::isnan, std:isfinite, std::isinf [Viktor Gal]
* Bugfixes:
- Port ipython notebooks to be python3 compatible [Viktor Gal]
- Use the shogun-static library on Windows when linking the interface library [Viktor Gal]
- Fix python typemap when compiling with MSVC [Viktor Gal]
- Fix ShogunConfig.cmake paths [Viktor Gal]
- Fix meta example parser bug in parallel builds [Esben Sørig]

2017-11-29 Viktor Gal <viktor.gal@shogun-toolbox.org>

* SHOGUN Release version 6.1.2 (libshogun 18.0, data 0.11, parameter 1)
Expand Down
9 changes: 6 additions & 3 deletions cmake/ShogunInterfaces.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ SET(INTERFACE_TARGET interface_${INTERFACE_NAME})
SET(INTERFACE_TARGET_SRC ${INTERFACE_TARGET}_src)

ADD_CUSTOM_TARGET(${INTERFACE_TARGET_SRC}
DEPENDS shogun::shogun ${INTERFACE_FILES}
DEPENDS ${INTERFACE_FILES}
COMMENT "copying SWIG files")

INCLUDE(${SWIG_USE_FILE})
Expand All @@ -43,8 +43,11 @@ IF(DEFINED TARGET_SWIGFLAGS)
ENDIF()
SET(SWIG_MODULE_${INTERFACE_NAME}_EXTRA_DEPS ${INTERFACE_FILES})
SWIG_ADD_MODULE(${INTERFACE_TARGET} ${INTERFACE_NAME} shogun.i sg_print_functions.cpp)
SWIG_LINK_LIBRARIES(${INTERFACE_TARGET} shogun::shogun ${INTERFACE_LIBRARIES})

IF (WIN32)
SWIG_LINK_LIBRARIES(${INTERFACE_TARGET} shogun::shogun-static ${INTERFACE_LIBRARIES})
ELSE ()
SWIG_LINK_LIBRARIES(${INTERFACE_TARGET} shogun::shogun ${INTERFACE_LIBRARIES})
ENDIF ()

#get_cmake_property(_variableNames VARIABLES)
#foreach (_variableName ${_variableNames})
Expand Down
44 changes: 22 additions & 22 deletions doc/ipython-notebooks/classification/MKL.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -171,17 +171,17 @@
"[gmm.set_nth_mean(means[i], i) for i in range(num_components)]\n",
"[gmm.set_nth_cov(covs,i) for i in range(num_components)]\n",
"gmm.set_coef(array([1.0,0.0,0.0,0.0]))\n",
"xntr=array([gmm.sample() for i in xrange(num)]).T\n",
"xnte=array([gmm.sample() for i in xrange(5000)]).T\n",
"xntr=array([gmm.sample() for i in range(num)]).T\n",
"xnte=array([gmm.sample() for i in range(5000)]).T\n",
"gmm.set_coef(array([0.0,1.0,0.0,0.0]))\n",
"xntr1=array([gmm.sample() for i in xrange(num)]).T\n",
"xnte1=array([gmm.sample() for i in xrange(5000)]).T\n",
"xntr1=array([gmm.sample() for i in range(num)]).T\n",
"xnte1=array([gmm.sample() for i in range(5000)]).T\n",
"gmm.set_coef(array([0.0,0.0,1.0,0.0]))\n",
"xptr=array([gmm.sample() for i in xrange(num)]).T\n",
"xpte=array([gmm.sample() for i in xrange(5000)]).T\n",
"xptr=array([gmm.sample() for i in range(num)]).T\n",
"xpte=array([gmm.sample() for i in range(5000)]).T\n",
"gmm.set_coef(array([0.0,0.0,0.0,1.0]))\n",
"xptr1=array([gmm.sample() for i in xrange(num)]).T\n",
"xpte1=array([gmm.sample() for i in xrange(5000)]).T\n",
"xptr1=array([gmm.sample() for i in range(num)]).T\n",
"xpte1=array([gmm.sample() for i in range(5000)]).T\n",
"traindata=concatenate((xntr,xntr1,xptr,xptr1), axis=1)\n",
"trainlab=concatenate((-ones(2*num), ones(2*num)))\n",
"\n",
Expand Down Expand Up @@ -269,7 +269,7 @@
"mkl.train() \n",
"\n",
"w=kernel.get_subkernel_weights()\n",
"print w"
"print(w)"
]
},
{
Expand Down Expand Up @@ -406,22 +406,22 @@
"out=mkl.apply()\n",
"\n",
"evaluator=ErrorRateMeasure()\n",
"print \"Test error is %2.2f%% :MKL\" % (100*evaluator.evaluate(out,BinaryLabels(testlab)))\n",
"print(\"Test error is %2.2f%% :MKL\" % (100*evaluator.evaluate(out,BinaryLabels(testlab))))\n",
"\n",
"\n",
"comb_ker0t.init(feats_train,RealFeatures(testdata)) \n",
"mkl.set_kernel(comb_ker0t)\n",
"out=mkl.apply()\n",
"\n",
"evaluator=ErrorRateMeasure()\n",
"print \"Test error is %2.2f%% :Subkernel1\"% (100*evaluator.evaluate(out,BinaryLabels(testlab)))\n",
"print(\"Test error is %2.2f%% :Subkernel1\"% (100*evaluator.evaluate(out,BinaryLabels(testlab))))\n",
"\n",
"comb_ker1t.init(feats_train, RealFeatures(testdata))\n",
"mkl.set_kernel(comb_ker1t)\n",
"out=mkl.apply()\n",
"\n",
"evaluator=ErrorRateMeasure()\n",
"print \"Test error is %2.2f%% :subkernel2\" % (100*evaluator.evaluate(out,BinaryLabels(testlab)))\n"
"print(\"Test error is %2.2f%% :subkernel2\" % (100*evaluator.evaluate(out,BinaryLabels(testlab))))\n"
]
},
{
Expand Down Expand Up @@ -546,7 +546,7 @@
"\n",
"\n",
"w, mkl=train_mkl(c, feats_tr)\n",
"print w\n",
"print(w)\n",
"out=test_mkl(mkl,grid)\n",
"\n",
"z=out.get_values().reshape((size, size))\n",
Expand Down Expand Up @@ -659,8 +659,8 @@
"Nsplit = 2\n",
"all_ks = range(1, 21)\n",
"\n",
"print Xall.shape\n",
"print Xtrain.shape"
"print(Xall.shape)\n",
"print(Xtrain.shape)"
]
},
{
Expand All @@ -679,7 +679,7 @@
"outputs": [],
"source": [
"def plot_example(dat, lab):\n",
" for i in xrange(5):\n",
" for i in range(5):\n",
" ax=subplot(1,5,i+1)\n",
" title(int(lab[i]))\n",
" ax.imshow(dat[:,i].reshape((16,16)), interpolation='nearest')\n",
Expand Down Expand Up @@ -753,7 +753,7 @@
"out = mkl.apply()\n",
"evaluator = MulticlassAccuracy()\n",
"accuracy = evaluator.evaluate(out, labels_rem)\n",
"print \"Accuracy = %2.2f%%\" % (100*accuracy)\n",
"print(\"Accuracy = %2.2f%%\" % (100*accuracy))\n",
"\n",
"idx=where(out.get_labels() != Yrem)[0]\n",
"Xbad=Xrem[:,idx]\n",
Expand All @@ -772,7 +772,7 @@
"outputs": [],
"source": [
"w=kernel.get_subkernel_weights()\n",
"print w"
"print(w)"
]
},
{
Expand All @@ -794,7 +794,7 @@
"evaluator = MulticlassAccuracy()\n",
"accuracy = evaluator.evaluate(out, labels_rem)\n",
"\n",
"print \"Accuracy = %2.2f%%\" % (100*accuracy)\n",
"print(\"Accuracy = %2.2f%%\" % (100*accuracy))\n",
"\n",
"idx=np.where(out.get_labels() != Yrem)[0]\n",
"Xbad=Xrem[:,idx]\n",
Expand Down Expand Up @@ -825,7 +825,7 @@
"evaluator = MulticlassAccuracy()\n",
"accuracy = evaluator.evaluate(out, labels_rem)\n",
"\n",
"print \"Accuracy = %2.2f%%\" % (100*accuracy)\n",
"print(\"Accuracy = %2.2f%%\" % (100*accuracy))\n",
"\n",
"idx=np.where(out.get_labels() != Yrem)[0]\n",
"Xbad=Xrem[:,idx]\n",
Expand Down Expand Up @@ -942,9 +942,9 @@
"outputs": [],
"source": [
"mkl.train()\n",
"print \"Weights:\"\n",
"print(\"Weights:\")\n",
"w=kernel.get_subkernel_weights()\n",
"print w\n",
"print(w)\n",
"\n",
"#initialize with test features\n",
"kernel.init(feats_train, feats_test) \n",
Expand Down
38 changes: 19 additions & 19 deletions doc/ipython-notebooks/classification/SupportVectorMachines.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@
"def solve (x1):\n",
" return -( ( (w[0])*x1 + b )/w[1] )\n",
"\n",
"x2=map(solve, x1)\n",
"x2=list(map(solve, x1))\n",
"\n",
"#plot\n",
"plt.figure(figsize=(6,6))\n",
Expand Down Expand Up @@ -395,7 +395,7 @@
"libsvm_obj=svm.get_objective()\n",
"primal_obj, dual_obj=svm.compute_svm_primal_objective(), svm.compute_svm_dual_objective()\n",
"\n",
"print libsvm_obj, primal_obj, dual_obj"
"print(libsvm_obj, primal_obj, dual_obj)"
]
},
{
Expand All @@ -413,7 +413,7 @@
},
"outputs": [],
"source": [
"print \"duality_gap\", dual_obj-primal_obj"
"print(\"duality_gap\", dual_obj-primal_obj)"
]
},
{
Expand Down Expand Up @@ -635,10 +635,10 @@
"gmm.set_nth_cov(np.array([[1.0,0.0],[0.0,1.0]]),1)\n",
"\n",
"gmm.set_coef(np.array([1.0,0.0]))\n",
"xntr=np.array([gmm.sample() for i in xrange(num)]).T\n",
"xntr=np.array([gmm.sample() for i in range(num)]).T\n",
"\n",
"gmm.set_coef(np.array([0.0,1.0]))\n",
"xptr=np.array([gmm.sample() for i in xrange(num)]).T\n",
"xptr=np.array([gmm.sample() for i in range(num)]).T\n",
"\n",
"traindata=np.concatenate((xntr,xptr), axis=1)\n",
"trainlab=np.concatenate((-np.ones(num), np.ones(num)))\n",
Expand Down Expand Up @@ -847,7 +847,7 @@
"\n",
"Err=sg.ErrorRateMeasure()\n",
"error=Err.evaluate(output, lab_test)\n",
"print 'Error:', error\n",
"print('Error:', error)\n",
"\n",
"#set normalization\n",
"gaussian_kernel=sg.GaussianKernel()\n",
Expand All @@ -863,7 +863,7 @@
"\n",
"Err=sg.ErrorRateMeasure()\n",
"error=Err.evaluate(output, lab_test)\n",
"print 'Error with normalization:', error"
"print('Error with normalization:', error)"
]
},
{
Expand Down Expand Up @@ -902,24 +902,24 @@
"[gmm.set_nth_mean(means[i], i) for i in range(num_components)]\n",
"[gmm.set_nth_cov(covs,i) for i in range(num_components)]\n",
"gmm.set_coef(np.array([1.0,0.0,0.0,0.0]))\n",
"xntr=np.array([gmm.sample() for i in xrange(num)]).T\n",
"xnte=np.array([gmm.sample() for i in xrange(5000)]).T\n",
"xntr=np.array([gmm.sample() for i in range(num)]).T\n",
"xnte=np.array([gmm.sample() for i in range(5000)]).T\n",
"gmm.set_coef(np.array([0.0,1.0,0.0,0.0]))\n",
"xntr1=np.array([gmm.sample() for i in xrange(num)]).T\n",
"xnte1=np.array([gmm.sample() for i in xrange(5000)]).T\n",
"xntr1=np.array([gmm.sample() for i in range(num)]).T\n",
"xnte1=np.array([gmm.sample() for i in range(5000)]).T\n",
"gmm.set_coef(np.array([0.0,0.0,1.0,0.0]))\n",
"xptr=np.array([gmm.sample() for i in xrange(num)]).T\n",
"xpte=np.array([gmm.sample() for i in xrange(5000)]).T\n",
"xptr=np.array([gmm.sample() for i in range(num)]).T\n",
"xpte=np.array([gmm.sample() for i in range(5000)]).T\n",
"gmm.set_coef(np.array([0.0,0.0,0.0,1.0]))\n",
"xptr1=np.array([gmm.sample() for i in xrange(num)]).T\n",
"xpte1=np.array([gmm.sample() for i in xrange(5000)]).T\n",
"xptr1=np.array([gmm.sample() for i in range(num)]).T\n",
"xpte1=np.array([gmm.sample() for i in range(5000)]).T\n",
"traindata=np.concatenate((xntr,xntr1,xptr,xptr1), axis=1)\n",
"testdata=np.concatenate((xnte,xnte1,xpte,xpte1), axis=1)\n",
"\n",
"l0 = np.array([0.0 for i in xrange(num)])\n",
"l1 = np.array([1.0 for i in xrange(num)])\n",
"l2 = np.array([2.0 for i in xrange(num)])\n",
"l3 = np.array([3.0 for i in xrange(num)])\n",
"l0 = np.array([0.0 for i in range(num)])\n",
"l1 = np.array([1.0 for i in range(num)])\n",
"l2 = np.array([2.0 for i in range(num)])\n",
"l3 = np.array([3.0 for i in range(num)])\n",
"\n",
"trainlab=np.concatenate((l0,l1,l2,l3))\n",
"testlab=np.concatenate((l0,l1,l2,l3))\n",
Expand Down
12 changes: 6 additions & 6 deletions doc/ipython-notebooks/clustering/KMeans.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@
"input": [
"def plotResult(title = 'KMeans Plot'):\n",
" figure,axis = pyplot.subplots(1,1)\n",
" for i in xrange(totalPoints):\n",
" for i in range(totalPoints):\n",
" if result[i]==0.0:\n",
" axis.plot(rectangle[0,i], rectangle[1,i], 'o', color='g', markersize=3)\n",
" else:\n",
Expand Down Expand Up @@ -638,7 +638,7 @@
"input": [
"# plot the clusters over the original points in 2 dimensions\n",
"figure,axis = pyplot.subplots(1,1)\n",
"for i in xrange(150):\n",
"for i in range(150):\n",
" if result[i]==0.0:\n",
" axis.plot(obsmatrix[2,i],obsmatrix[3,i],'ko',color='r', markersize=5)\n",
" elif result[i]==1.0:\n",
Expand Down Expand Up @@ -707,7 +707,7 @@
" return (diff,accuracy)\n",
"\n",
"(diff,accuracy_4d) = analyzeResult(result)\n",
"print 'Accuracy : ' + str(accuracy_4d)\n",
"print('Accuracy : ' + str(accuracy_4d))\n",
"\n",
"# plot the difference between ground truth and predicted clusters\n",
"figure,axis = pyplot.subplots(1,1)\n",
Expand Down Expand Up @@ -839,7 +839,7 @@
"collapsed": false,
"input": [
"(diff,accuracy_1d) = analyzeResult(result)\n",
"print 'Accuracy : ' + str(accuracy_1d)\n",
"print('Accuracy : ' + str(accuracy_1d))\n",
"\n",
"# plot the difference between ground truth and predicted clusters\n",
"figure,axis = pyplot.subplots(1,1)\n",
Expand Down Expand Up @@ -925,7 +925,7 @@
"collapsed": false,
"input": [
"(diff,accuracy_2d) = analyzeResult(result)\n",
"print 'Accuracy : ' + str(accuracy_2d)\n",
"print('Accuracy : ' + str(accuracy_2d))\n",
"\n",
"# plot the difference between ground truth and predicted clusters\n",
"figure,axis = pyplot.subplots(1,1)\n",
Expand Down Expand Up @@ -1001,7 +1001,7 @@
"collapsed": false,
"input": [
"(diff,accuracy_3d) = analyzeResult(result)\n",
"print 'Accuracy : ' + str(accuracy_3d)\n",
"print('Accuracy : ' + str(accuracy_3d))\n",
"\n",
"# plot the difference between ground truth and predicted clusters\n",
"figure,axis = pyplot.subplots(1,1)\n",
Expand Down
10 changes: 5 additions & 5 deletions doc/ipython-notebooks/distributions/KernelDensity.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@
"\n",
"# generates samples from the distribution\n",
"def generate_samples(n_samples,mu1,sigma1,mu2,sigma2):\n",
" samples1 = np.random.normal(mu1,sigma1,(1,n_samples/2))\n",
" samples2 = np.random.normal(mu2,sigma2,(1,n_samples/2))\n",
" samples1 = np.random.normal(mu1,sigma1,(1,int(n_samples/2)))\n",
" samples2 = np.random.normal(mu2,sigma2,(1,int(n_samples/2)))\n",
" samples = np.concatenate((samples1,samples2),1)\n",
" return samples\n",
"\n",
Expand Down Expand Up @@ -383,7 +383,7 @@
" query_feats=RealFeatures(np.array([x[0,:],y[0,:]]))\n",
" z=np.array([kdestimator.get_log_density(query_feats)])\n",
" z=np.exp(z)\n",
" for i in xrange(1,x.shape[0]):\n",
" for i in range(1,x.shape[0]):\n",
" query_feats=RealFeatures(np.array([x[i,:],y[i,:]]))\n",
" zi=np.exp(kdestimator.get_log_density(query_feats))\n",
" z=np.vstack((z,zi))\n",
Expand Down Expand Up @@ -441,9 +441,9 @@
"\n",
"# classify using our decision rule\n",
"z=[]\n",
"for i in xrange(0,x.shape[0]):\n",
"for i in range(0,x.shape[0]):\n",
" zj=[]\n",
" for j in xrange(0,x.shape[1]):\n",
" for j in range(0,x.shape[1]):\n",
" if ((z1[i,j]>z2[i,j]) and (z1[i,j]>z3[i,j])):\n",
" zj.append(1)\n",
" elif (z2[i,j]>z3[i,j]):\n",
Expand Down
Loading

0 comments on commit 94be17f

Please sign in to comment.