Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
from enum import Enum
class Estimator(Enum):
SVC = "SVC"
KNeighborsClassifier = "KNeighborsClassifier"
RandomForestClassifier = "RandomForestClassifier"
SGDClassifier = "SGDClassifier"
SGDRegressor = "SGDRegressor"
SVR = "SVR"
MiniBatchKMeans = "MiniBatchKMeans"
KMeans = "KMeans"
content = {}
content[Estimator.SVC.value] = {
"import": "from sklearn.svm import SVC",
"doc_link": "https://scikit-learn.org/stable\
/modules/generated/sklearn.svm.SVC.html#sklearn.svm.SVC",
"evaluation": "classification",
}
content[Estimator.KNeighborsClassifier.value] = {
"import": "from sklearn.neighbors import KNeighborsClassifier",
"doc_link": "https://scikit-learn.org/stable/modules/neighbors.html",
"evaluation": "classification",
}
content[Estimator.RandomForestClassifier.value] = {
"import": "from sklearn.ensemble import RandomForestClassifier",
"doc_link": "https://scikit-learn.org/stable\
/modules/generated/sklearn.ensemble.Random\
ForestClassifier.html#sklearn.ensemble.RandomForestClassifier",
"evaluation": "classification",
"evaluation": "regression",
}
content[Estimator.SVR.value] = {
"import": "from sklearn.svm import SVR",
"doc_link": "https://scikit-learn.org/\
stable/modules/generated/sklearn.svm.\
SVR.html#sklearn.svm.SVR",
"evaluation": "regression",
}
content[Estimator.MiniBatchKMeans.value] = {
"import": "from sklearn.cluster import MiniBatchKMeans",
"doc_link": "https://scikit-learn.org/\
stable/modules/clustering.html#mini-batch-k-means",
"evaluation": "classification",
}
content[Estimator.KMeans.value] = {
"import": "from sklearn.cluster import KMeans",
"doc_link": "https://scikit-learn.org/\
stable/modules/clustering.html#k-means",
"evaluation": "clustering",
}
metrics = {
"regression": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Regression Evaluation Metrics\n",
"\n",
"\n",
content[Estimator.RandomForestClassifier.value] = {
"import": "from sklearn.ensemble import RandomForestClassifier",
"doc_link": "https://scikit-learn.org/stable\
/modules/generated/sklearn.ensemble.Random\
ForestClassifier.html#sklearn.ensemble.RandomForestClassifier",
"evaluation": "classification",
}
content[Estimator.SGDClassifier.value] = {
"import": "from sklearn.linear_model import SGDClassifier",
"doc_link": "https://scikit-learn.org/\
stable/modules/generated/sklearn.linear\
_model.SGDClassifier.html#sklearn.\
linear_model.SGDClassifier",
"evaluation": "classification",
}
content[Estimator.SGDRegressor.value] = {
"import": "from sklearn.linear_model import SGDRegressor",
"doc_link": "https://scikit-learn.org\
/stable/modules/generated/sklearn.linear\
_model.SGDRegressor.html#sklearn.linear_model.SGDRegressor",
"evaluation": "regression",
}
content[Estimator.SVR.value] = {
"import": "from sklearn.svm import SVR",
"doc_link": "https://scikit-learn.org/\
stable/modules/generated/sklearn.svm.\
SVR.html#sklearn.svm.SVR",
"evaluation": "regression",
}
content[Estimator.MiniBatchKMeans.value] = {
"import": "from sklearn.cluster import MiniBatchKMeans",
"doc_link": "https://scikit-learn.org/\
RandomForestClassifier = "RandomForestClassifier"
SGDClassifier = "SGDClassifier"
SGDRegressor = "SGDRegressor"
SVR = "SVR"
MiniBatchKMeans = "MiniBatchKMeans"
KMeans = "KMeans"
content = {}
content[Estimator.SVC.value] = {
"import": "from sklearn.svm import SVC",
"doc_link": "https://scikit-learn.org/stable\
/modules/generated/sklearn.svm.SVC.html#sklearn.svm.SVC",
"evaluation": "classification",
}
content[Estimator.KNeighborsClassifier.value] = {
"import": "from sklearn.neighbors import KNeighborsClassifier",
"doc_link": "https://scikit-learn.org/stable/modules/neighbors.html",
"evaluation": "classification",
}
content[Estimator.RandomForestClassifier.value] = {
"import": "from sklearn.ensemble import RandomForestClassifier",
"doc_link": "https://scikit-learn.org/stable\
/modules/generated/sklearn.ensemble.Random\
ForestClassifier.html#sklearn.ensemble.RandomForestClassifier",
"evaluation": "classification",
}
content[Estimator.SGDClassifier.value] = {
"import": "from sklearn.linear_model import SGDClassifier",
"doc_link": "https://scikit-learn.org/\
stable/modules/generated/sklearn.linear\
_model.SGDClassifier.html#sklearn.\
def grid_search(estimator):
if estimator not in [Estimator.SVC.value, Estimator.SVR.value]:
return []
return [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Gridsearch\n",
"\n",
"Finding the right parameters (like what C or gamma values to use) \
is a tricky task. We can adopt a trial and error approach to \
find the best fit. Through GridSearch, we can try different \
combinations of parameters and roll with the best option. \
You just need to feed a dictionary with possible parameters \
and Scikit-learn will use the one with \
the best score on the next train fit!",
}
content[Estimator.SGDRegressor.value] = {
"import": "from sklearn.linear_model import SGDRegressor",
"doc_link": "https://scikit-learn.org\
/stable/modules/generated/sklearn.linear\
_model.SGDRegressor.html#sklearn.linear_model.SGDRegressor",
"evaluation": "regression",
}
content[Estimator.SVR.value] = {
"import": "from sklearn.svm import SVR",
"doc_link": "https://scikit-learn.org/\
stable/modules/generated/sklearn.svm.\
SVR.html#sklearn.svm.SVR",
"evaluation": "regression",
}
content[Estimator.MiniBatchKMeans.value] = {
"import": "from sklearn.cluster import MiniBatchKMeans",
"doc_link": "https://scikit-learn.org/\
stable/modules/clustering.html#mini-batch-k-means",
"evaluation": "classification",
}
content[Estimator.KMeans.value] = {
"import": "from sklearn.cluster import KMeans",
"doc_link": "https://scikit-learn.org/\
stable/modules/clustering.html#k-means",
"evaluation": "clustering",
}
metrics = {
"regression": [
{
/modules/generated/sklearn.svm.SVC.html#sklearn.svm.SVC",
"evaluation": "classification",
}
content[Estimator.KNeighborsClassifier.value] = {
"import": "from sklearn.neighbors import KNeighborsClassifier",
"doc_link": "https://scikit-learn.org/stable/modules/neighbors.html",
"evaluation": "classification",
}
content[Estimator.RandomForestClassifier.value] = {
"import": "from sklearn.ensemble import RandomForestClassifier",
"doc_link": "https://scikit-learn.org/stable\
/modules/generated/sklearn.ensemble.Random\
ForestClassifier.html#sklearn.ensemble.RandomForestClassifier",
"evaluation": "classification",
}
content[Estimator.SGDClassifier.value] = {
"import": "from sklearn.linear_model import SGDClassifier",
"doc_link": "https://scikit-learn.org/\
stable/modules/generated/sklearn.linear\
_model.SGDClassifier.html#sklearn.\
linear_model.SGDClassifier",
"evaluation": "classification",
}
content[Estimator.SGDRegressor.value] = {
"import": "from sklearn.linear_model import SGDRegressor",
"doc_link": "https://scikit-learn.org\
/stable/modules/generated/sklearn.linear\
_model.SGDRegressor.html#sklearn.linear_model.SGDRegressor",
"evaluation": "regression",
}
content[Estimator.SVR.value] = {
"import": "from sklearn.svm import SVR",
KMeans = "KMeans"
content = {}
content[Estimator.SVC.value] = {
"import": "from sklearn.svm import SVC",
"doc_link": "https://scikit-learn.org/stable\
/modules/generated/sklearn.svm.SVC.html#sklearn.svm.SVC",
"evaluation": "classification",
}
content[Estimator.KNeighborsClassifier.value] = {
"import": "from sklearn.neighbors import KNeighborsClassifier",
"doc_link": "https://scikit-learn.org/stable/modules/neighbors.html",
"evaluation": "classification",
}
content[Estimator.RandomForestClassifier.value] = {
"import": "from sklearn.ensemble import RandomForestClassifier",
"doc_link": "https://scikit-learn.org/stable\
/modules/generated/sklearn.ensemble.Random\
ForestClassifier.html#sklearn.ensemble.RandomForestClassifier",
"evaluation": "classification",
}
content[Estimator.SGDClassifier.value] = {
"import": "from sklearn.linear_model import SGDClassifier",
"doc_link": "https://scikit-learn.org/\
stable/modules/generated/sklearn.linear\
_model.SGDClassifier.html#sklearn.\
linear_model.SGDClassifier",
"evaluation": "classification",
}
content[Estimator.SGDRegressor.value] = {
"import": "from sklearn.linear_model import SGDRegressor",
content[Estimator.SVC.value] = {
"import": "from sklearn.svm import SVC",
"doc_link": "https://scikit-learn.org/stable/modules/generated/sklearn.svm.SVC.html#sklearn.svm.SVC",
"evaluation": "classification"
}
content[Estimator.KNeighborsClassifier.value] = {
"import": "from sklearn.neighbors import KNeighborsClassifier",
"doc_link": "https://scikit-learn.org/stable/modules/neighbors.html",
"evaluation": "classification"
}
content[Estimator.RandomForestClassifier.value] = {
"import": "from sklearn.ensemble import RandomForestClassifier",
"doc_link": "https://scikit-learn.org/stable/modules/generated/sklearn.ensemble.RandomForestClassifier.html#sklearn.ensemble.RandomForestClassifier",
"evaluation": "classification"
}
content[Estimator.SGDClassifier.value] = {
"import": "from sklearn.linear_model import SGDClassifier",
"doc_link": "https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.SGDClassifier.html#sklearn.linear_model.SGDClassifier",
"evaluation": "classification"
}
content[Estimator.SGDRegressor.value] = {
"import": "from sklearn.linear_model import SGDRegressor",
"doc_link": "https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.SGDRegressor.html#sklearn.linear_model.SGDRegressor",
"evaluation": "regression"
}
content[Estimator.SVR.value] = {
"import": "from sklearn.svm import SVR",
"doc_link": "https://scikit-learn.org/stable/modules/generated/sklearn.svm.SVR.html#sklearn.svm.SVR",
"evaluation": "regression"
}
content[Estimator.MiniBatchKMeans.value] = {
"import": "from sklearn.cluster import MiniBatchKMeans",
content[Estimator.SGDClassifier.value] = {
"import": "from sklearn.linear_model import SGDClassifier",
"doc_link": "https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.SGDClassifier.html#sklearn.linear_model.SGDClassifier",
"evaluation": "classification"
}
content[Estimator.SGDRegressor.value] = {
"import": "from sklearn.linear_model import SGDRegressor",
"doc_link": "https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.SGDRegressor.html#sklearn.linear_model.SGDRegressor",
"evaluation": "regression"
}
content[Estimator.SVR.value] = {
"import": "from sklearn.svm import SVR",
"doc_link": "https://scikit-learn.org/stable/modules/generated/sklearn.svm.SVR.html#sklearn.svm.SVR",
"evaluation": "regression"
}
content[Estimator.MiniBatchKMeans.value] = {
"import": "from sklearn.cluster import MiniBatchKMeans",
"doc_link": "https://scikit-learn.org/stable/modules/clustering.html#mini-batch-k-means",
"evaluation": "classification"
}
content[Estimator.KMeans.value] = {
"import": "from sklearn.cluster import KMeans",
"doc_link": "https://scikit-learn.org/stable/modules/clustering.html#k-means",
"evaluation": "clustering"
}
metrics = {
"regression": [
{
"cell_type": "markdown",
"metadata": {},