To receive notifications about scheduled maintenance, please subscribe to the mailing-list gitlab-operations@sympa.ethz.ch. You can subscribe to the mailing-list at https://sympa.ethz.ch

Commit b71629ce authored by Ard Kastrati's avatar Ard Kastrati
Browse files

Prepared the experiment for kNN

parent 3c25aa75
......@@ -27,7 +27,7 @@ from config import config
def cross_validate_kNN(X, y):
logging.info("Cross-validation KNN...")
classifier = KNeighborsClassifier(weights='uniform', algorithm='auto', n_jobs=-1)
parameters_KNN = {'n_neighbors': [5, 10, 50], 'leaf_size': [10, 30]}
parameters_KNN = {'n_neighbors': [5, 25, 100], 'leaf_size': [10, 50]}
cross_validate(classifier=classifier, parameters=parameters_KNN, X=X, y=y)
def cross_validate_SVC(X, y):
......@@ -44,7 +44,7 @@ def cross_validate_RFC(X, y):
def cross_validate(classifier, parameters, X, y):
X = X.reshape((36223, 500 * 129))
clf = GridSearchCV(classifier, parameters, scoring='accuracy', n_jobs=-1, verbose=3)
clf = GridSearchCV(classifier, parameters, scoring='accuracy', n_jobs=-1, verbose=3, cv=2)
clf.fit(X, y.ravel())
export_dict(clf.cv_results_['mean_fit_time'], clf.cv_results_['std_fit_time'], clf.cv_results_['mean_score_time'],
......@@ -60,17 +60,17 @@ def try_sklearn_classifiers(X, y):
logging.info("Training the simple classifiers: kNN, Linear SVM, Random Forest and Naive Bayes.")
names = [# "Nearest Neighbors",
# "Linear SVM",
"Random Forest",
"Naive Bayes",
# "Random Forest",
# "Naive Bayes",
"Linear SVM"
]
classifiers = [
# KNeighborsClassifier(n_neighbors=5, weights='uniform', algorithm='auto', leaf_size=30, n_jobs=-1),
# LinearSVC(tol=1e-5, C=1, random_state=42, max_iter=1000),
RandomForestClassifier(n_estimators=30, max_depth=20, max_features='auto', random_state=42, n_jobs=-1),
GaussianNB(),
LinearSVC(tol=1e-3, C=5, random_state=42, max_iter=500)
# RandomForestClassifier(n_estimators=30, max_depth=20, max_features='auto', random_state=42, n_jobs=-1),
# GaussianNB(),
LinearSVC(tol=1e-3, C=20, random_state=42, max_iter=500)
]
X = X.reshape((36223, 500 * 129))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment