-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from asfadmin/sg/ml
Sg/ml
- Loading branch information
Showing
38 changed files
with
264 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
inputs: | ||
path: | ||
type: Str | ||
user_input: True | ||
user_input: Text | ||
outputs: | ||
success: | ||
type: Bool | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
inputs: | ||
input_string: | ||
type: Str | ||
user_input: True | ||
user_input: Text | ||
outputs: | ||
output_string: | ||
type: Str | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,5 @@ convert | |
example | ||
image | ||
math | ||
ml | ||
string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
a: | ||
type: Number | ||
default: 0 | ||
user_input: True | ||
user_input: Text | ||
outputs: | ||
sum: | ||
type: Number | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
""" | ||
name: "Cross Validation Score" | ||
requirements: | ||
- numpy | ||
- scikit-learn | ||
inputs: | ||
X: | ||
type: !CustomClass numpy.ndarray | ||
y: | ||
type: !CustomClass numpy.ndarray | ||
model: | ||
type: !CustomClass sklearn.neural_network._multilayer_perceptron.MLPClassifier | ||
outputs: | ||
mean: | ||
type: Number | ||
standard_deviation: | ||
type: Number | ||
description: "Returns a trained sklearn MLP" | ||
""" | ||
|
||
import numpy as np | ||
from sklearn.neural_network import MLPClassifier | ||
from sklearn.model_selection import cross_val_score | ||
|
||
def main(X:np.ndarray, y:np.ndarray, model:MLPClassifier): | ||
scores = cross_val_score(model, X, y) | ||
return scores.mean(), scores.std() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
""" | ||
name: "Import SKlearn Dataset" | ||
requirements: | ||
- numpy | ||
- scikit-learn | ||
inputs: | ||
dataset_name: | ||
type: Str | ||
user_input: Dropdown | ||
options: | ||
- "breast_cancer" | ||
- "diabetes" | ||
- "digits" | ||
- "iris" | ||
- "linnerud" | ||
- "wine" | ||
n_class: | ||
type: Number | ||
default: None | ||
user_input: Text | ||
scaled: | ||
type: Bool | ||
default: None | ||
user_input: Text | ||
outputs: | ||
X: | ||
type: !CustomClass numpy.ndarray | ||
y: | ||
type: !CustomClass numpy.ndarray | ||
description: "Returns a dataset loaded from sklearn" | ||
""" | ||
|
||
from sklearn import datasets | ||
import logging | ||
logging.basicConfig(format='%(asctime)s - %(message)s', level=logging.INFO) | ||
|
||
def main(dataset_name:str, n_class:int=None, scaled:bool=None): | ||
logging.info(f"Starting to import {dataset_name}") | ||
|
||
## Temporary set "None" to None | ||
## Remove after scipyflow issue #116 is completed | ||
if n_class == "None": | ||
n_class = None | ||
if scaled == "None": | ||
scaled = None | ||
## End temporary code | ||
|
||
dataset_name = dataset_name.lower() | ||
kwargs = { | ||
'return_X_y':True, | ||
'as_frame':False, | ||
} | ||
|
||
if dataset_name == "breast_cancer": | ||
return datasets.load_breast_cancer(**kwargs) | ||
|
||
elif dataset_name == "diabetes": | ||
if scaled: | ||
kwargs[scaled] = scaled | ||
return datasets.load_diabetes(**kwargs) | ||
|
||
elif dataset_name == "digits": | ||
if n_class: | ||
kwargs[n_class] = n_class | ||
return datasets.load_digits(**kwargs) | ||
|
||
elif dataset_name == "iris": | ||
return datasets.load_iris(**kwargs) | ||
|
||
elif dataset_name == "linnerud": | ||
return datasets.load_linnerud(**kwargs) | ||
|
||
elif dataset_name == "wine": | ||
return datasets.load_wine(**kwargs) | ||
|
||
else: | ||
logging.info(f"Cannot find dataset '{dataset_name}'") | ||
return None, None |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
""" | ||
name: "Load Model" | ||
requirements: | ||
- numpy | ||
- scikit-learn | ||
inputs: | ||
X: | ||
type: !CustomClass numpy.ndarray | ||
y: | ||
type: !CustomClass numpy.ndarray | ||
model: | ||
type: !CustomClass sklearn.neural_network._multilayer_perceptron.MLPClassifier | ||
outputs: | ||
score: | ||
type: Number | ||
description: "Returns a trained sklearn MLP" | ||
""" | ||
|
||
import numpy as np | ||
from sklearn.neural_network import MLPClassifier | ||
|
||
def main(X:np.ndarray, y: np.ndarray, model:MLPClassifier): | ||
pass |
Oops, something went wrong.