----------- Learning ------------------
"""

weights = 'distance'
n_neighbors = 15
# we create an instance of Neighbours Classifier and fit the data.
clf = neighbors.KNeighborsClassifier(n_neighbors, weights=weights)
clf.fit(norm_data, labels)

# DetectionMethods.detect_with_cross_validation(clf, norm_data, labels)
"""
------------- Testing -------------
"""
norm_test_data, test_labels = Get_normalize_data.main2(final_path,
                                                       "test_connections.txt")
DetectionMethods.detect(clf, norm_test_data, test_labels)

X = np.array(norm_data)
y = np.array(labels)
h = .02
"""
------------- Ploting -------------
"""
# Create color maps
# cmap_light = ListedColormap(['#FFAAAA', '#AAFFAA', '#AAAAFF'])
# cmap_bold = ListedColormap(['#FF0000', '#00FF00', '#0000FF'])
# # Plot the decision boundary. For that, we will assign a color to each
# # point in the mesh [x_min, x_max]x[y_min, y_max].
# x_min, x_max = X[:, 0].min() - 1, X[:, 0].max() + 1
# y_min, y_max = X[:, 1].min() - 1, X[:, 1].max() + 1
# xx, yy = np.meshgrid(np.arange(x_min, x_max, h),
示例#2
0
"""
Read data model 1
"""
X_train, X_test, y_train, y_test = Get_normalize_data.get_all_data(final_path)




clf = MLPClassifier(solver='adam', alpha=1e-05, random_state=1)


"""
Crossvalidation
"""
DetectionMethods.detect_with_cross_validation(clf, X_train, y_train)

"""
Learning
"""
clf.fit(X_train, y_train)

"""
Detect
"""
DetectionMethods.detect(clf, X_test, y_test)

# score = clf.score(X_test, y_test)
# print score

示例#3
0
     # colsample_bytree=0.8,
     # objective= 'binary:logistic',
     # nthread=4,
     # scale_pos_weight=1,
     # seed=27)
	 
# title = "Learning Curves ( XGBoost s)"
model = XGBClassifier(
	learning_rate=0.1,
  n_estimators=1000,
  max_depth=3,
  min_child_weight=5,
  gamma=0.1,
  subsample=0.8,
  colsample_bytree=0.8,
  objective='binary:logistic',
  nthread=4,
  scale_pos_weight=1,
  seed=27)

"""
Crossvalidation
"""
DetectionMethods.detect_with_cross_validation(model, np_X_train, np_y_train)

"""
Detect model
"""
# model = XGBClassifier()
model.fit(np_X_train, np_y_train)
DetectionMethods.detect(model, np_X_test, np_y_test)