Skip to content
Snippets Groups Projects
Commit e60cd236 authored by Nelly Barret's avatar Nelly Barret
Browse files

[M] paper JOSS

parent bddd5a57
No related branches found
No related tags found
No related merge requests found
This diff is collapsed.
predihood-indicators.png

557 KiB

......@@ -2,7 +2,7 @@ class Classifier:
# def __init__(self):
def fit(self, X, y):
return None
raise Exception("You must implement your own fit function.")
def predict(self, df):
return ["default_value"]
raise Exception("You must implement your own predict function.")
......@@ -32,6 +32,8 @@ class MethodPrediction(Method):
"""
Compute performance metrics, i.e. accuracy.
"""
print(self.dataset.X)
print(self.dataset.Y)
scores = cross_val_score(self.classifier, self.dataset.X, self.dataset.Y, cv=5, scoring="accuracy")
self.accuracy = scores.mean() * 100
print(self.accuracy)
......
......@@ -2,14 +2,24 @@ from predihood.classes.Classifier import Classifier
class NewAlgorithm(Classifier):
"""
A new algorithm.
Parameters
----------
alpha : int, default=1
The first parameter.
beta : str, default="2"
The second parameter.
"""
def __init__(self, alpha=1, beta="2"):
Classifier.__init__(self)
self.alpha = alpha
self.beta = beta
def fit(self, X, y):
print("here")
return None
return self
def predict(self, df):
print("there")
......
......@@ -7,12 +7,14 @@ from sklearn.svm import SVC
from sklearn.tree import DecisionTreeClassifier
# to add a new classifier, add as key the name of your classifier and as value the name of the class that implement your classifier.
# do not forget to import your classifier
AVAILABLE_CLASSIFIERS = {
"RandomForestClassifier": RandomForestClassifier,
"KNeighborsClassifier": KNeighborsClassifier,
"DecisionTreeClassifier": DecisionTreeClassifier,
"Random Forest Classifier": RandomForestClassifier,
"KNeighbors Classifier": KNeighborsClassifier,
"Decision Tree Classifier": DecisionTreeClassifier,
"SVC": SVC,
"AdaBoostClassifier": AdaBoostClassifier,
"MLPClassifier": MLPClassifier,
"NewAlgorithm": NewAlgorithm
"AdaBoost Classifier": AdaBoostClassifier,
"MLP Classifier": MLPClassifier,
"New Algorithm": NewAlgorithm
}
......@@ -221,13 +221,16 @@ def signature(chosen_algorithm):
try:
# model = eval(_chosen_algorithm) # never use eval on untrusted strings
model = get_classifier(chosen_algorithm)
print(model)
doc = model.__doc__ # TODO: specify case when there is no doc (user-implemented algorithm)
print(doc)
param_section = "Parameters"
dashes = "-" * len(param_section) # -------
number_spaces = doc.find(dashes) - (doc.find(param_section) + len(param_section))
attribute_section = "Attributes\n"
# sub_doc is the param section of the docs (i.e. without attributes and some text)
sub_doc = doc[doc.find(param_section) + len(param_section) + number_spaces + len(dashes) + len("\n"):doc.find(attribute_section)]
print(sub_doc)
except:
raise Exception("This algorithm does not exist for the moment...")
params = inspect.getfullargspec(model.__init__).args[1:] # get parameter' names -- [1:] to remove self parameter
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment