if INTERACTIVE:
    import matplotlib.pyplot as plt

import numpy as np
np.random.seed(8)
from plottools import make_spiral, point_prob_plot, probaproxy, accuracy_score
#plt.rc('text', usetex=True)
#plt.rc('font', family='serif')
np.random.seed(1)

#%% Prepare...
n_classes = 2
n_trees = 200
ploty = [-6, 6, 100]
plotx = [-6, 6, 100]
X, Y = make_spiral(n_arms=n_classes, noise=.4)

# Forest.
soil = f.Soil()
dec_name = 'quadratic'
rs = 1
suggestions = 5
depth = 5
if dec_name == 'aligned':
    feat_sel_prov = soil.StandardFeatureSelectionProvider(2,
                                                          1,
                                                          2,
                                                          2,
                                                          random_seed=rs)
else:
    feat_sel_prov = soil.StandardFeatureSelectionProvider(1, 2, 2, 2)
Beispiel #2
0
  INTERACTIVE = False
else:
  INTERACTIVE = True

from fertilized import *
import numpy as np
from plottools import make_spiral, point_prob_plot, accuracy_score

# Only for plotting, evaluation.
if INTERACTIVE:
    import matplotlib.pyplot as plt

np.random.seed(8)

# Generate the spiral dataset for further use.
X, Y = make_spiral()
plotx = [-6, 6, 100]
ploty = [-6, 6, 100]

if INTERACTIVE:
    plt.scatter(X[:, 0], X[:, 1], c=Y)
    plt.show()

soil = Soil('f', 'f', 'uint', Result_Types.probabilities)

###############################################################################
# Lets build a customized forest:
depth = 6
n_trees = 200
# These variables will contain the classifiers and leaf managers for each tree.
cls = []
Beispiel #3
0
import matplotlib.cm as cm
import matplotlib.mlab as mlab
import matplotlib.pyplot as plt
import numpy as np
from plottools import make_spiral, point_prob_plot, probaproxy
plt.rc('text', usetex=True)
plt.rc('font', family='serif')

np.random.seed(1)

n_classes = 2
n_trees = 200
ploty = [-6, 6, 100]
plotx = [-6, 6, 100]

X, Y = make_spiral(n_arms=n_classes, noise=.4)

##############################################################################
parameters = {'kernel': ['rbf'],
              'C': [1, 10, 100, 1000, 10000, 100000],
              'gamma': [10 ** x for x in range(-5, 3)],
              'probability':[True]}
svr = svm.SVC()
clf = grid_search.GridSearchCV(svr, parameters)
clf.fit(X, Y.ravel())

svmp = probaproxy(clf.predict_proba)

plt.figure()
point_prob_plot(svmp, X, Y, plotx, ploty)
plt.title('RBF kernel SVM $(\gamma=%d, C=%f)$' % (clf.best_params_['gamma'], clf.best_params_['C']))
    INTERACTIVE = False
else:
    INTERACTIVE = True

from fertilized import *
import numpy as np
from plottools import make_spiral, point_prob_plot, accuracy_score

# Only for plotting, evaluation.
if INTERACTIVE:
    import matplotlib.pyplot as plt

np.random.seed(8)

# Generate the spiral dataset for further use.
X, Y = make_spiral()
plotx = [-6, 6, 100]
ploty = [-6, 6, 100]

if INTERACTIVE:
    plt.scatter(X[:, 0], X[:, 1], c=Y)
    plt.show()

soil = Soil('f', 'f', 'uint', Result_Types.probabilities)

###############################################################################
# Lets build a customized forest:
depth = 6
n_trees = 200
# These variables will contain the classifiers and leaf managers for each tree.
cls = []