Skip to content

Instantly share code, notes, and snippets.

@HackerEarthBlog
HackerEarthBlog / parameter_tuning.py
Last active June 14, 2019 06:43
Parameter tuning for SVM using Grid Search
from sklearn.model_selection import GridSearchCV
parameters = {'kernel':('linear', 'rbf'), 'C':[1,2,3,4,5,6,7,8,9,10], 'gamma':
[0.01,0.02,0.03,0.04,0.05,0.10,0.2,0.3,0.4,0.5]}
svr = svm.SVC()
grid = GridSearchCV(svr, parameters)
grid.fit(X_train, y_train)
predicted = grid.predict(X_test)
cnf_matrix = confusion_matrix(y_test, predicted)
print(cnf_matrix)
@HackerEarthBlog
HackerEarthBlog / Apriori.R
Last active May 17, 2020 10:41
Apriori Algorithm in R
> library(arules)
> data("Adult")
> rules <- apriori(Adult,parameter = list(supp = 0.5, conf = 0.9, target = "rules"))
> summary(rules)
#set of 52 rules
#rule length distribution (lhs + rhs):sizes
# 1 2 3 4
# 2 13 24 13