-
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 #31 from JannisHoch/leave_one_out
v0.0.2
- Loading branch information
Showing
11 changed files
with
2,486 additions
and
236 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -128,8 +128,5 @@ dmypy.json | |
# Pyre type checker | ||
.pyre/ | ||
|
||
# run settings | ||
*/run_setting.cfg | ||
|
||
#output folders | ||
OUT*/ |
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,6 +4,7 @@ | |
from . import utils | ||
from . import get_boolean_conflict | ||
from . import get_var_from_nc | ||
from . import machine_learning | ||
|
||
__author__ = """Jannis M. Hoch""" | ||
__email__ = '[email protected]' | ||
|
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 |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import os | ||
from sklearn import svm, neighbors, preprocessing | ||
|
||
def define_scaling(config): | ||
"""[summary] | ||
Args: | ||
config ([type]): [description] | ||
Raises: | ||
ValueError: [description] | ||
Returns: | ||
[type]: [description] | ||
""" | ||
|
||
if config.getboolean('general', 'sensitivity_analysis'): | ||
scalers = [preprocessing.MinMaxScaler(), | ||
preprocessing.StandardScaler(), | ||
preprocessing.RobustScaler(), | ||
preprocessing.QuantileTransformer(random_state=42)] | ||
|
||
elif not config.getboolean('general', 'sensitivity_analysis'): | ||
if config.get('machine_learning', 'scaler') == 'MinMaxScaler': | ||
scalers = [preprocessing.MinMaxScaler()] | ||
elif config.get('machine_learning', 'scaler') == 'StandardScaler': | ||
scalers = [preprocessing.StandardScaler()] | ||
elif config.get('machine_learning', 'scaler') == 'RobustScaler': | ||
scalers = [preprocessing.RobustScaler()] | ||
elif config.get('machine_learning', 'scaler') == 'QuantileTransformer': | ||
scalers = [preprocessing.QuantileTransformer(random_state=42)] | ||
else: | ||
raise ValueError('no supported scaling-algorithm selected - choose between MinMaxScaler, StandardScaler, RobustScaler or QuantileTransformer') | ||
|
||
print('chosen scaling method is {}'.format(scalers[0])) | ||
|
||
return scalers | ||
|
||
def define_model(config): | ||
"""[summary] | ||
Args: | ||
config ([type]): [description] | ||
Raises: | ||
ValueError: [description] | ||
Returns: | ||
[type]: [description] | ||
""" | ||
|
||
if config.getboolean('general', 'sensitivity_analysis'): | ||
clfs = [svm.NuSVC(nu=0.1, kernel='rbf', class_weight={1: 100}, random_state=42, probability=True, degree=10, gamma=10), | ||
neighbors.KNeighborsClassifier(n_neighbors=10, weights='distance')] | ||
|
||
elif not config.getboolean('general', 'sensitivity_analysis'): | ||
if config.get('machine_learning', 'model') == 'NuSVC': | ||
clfs = [svm.NuSVC(nu=0.1, kernel='rbf', class_weight={1: 100}, random_state=42, probability=True, degree=10, gamma=10)] | ||
elif config.get('machine_learning', 'model') == 'KNeighborsClassifier': | ||
clfs = [neighbors.KNeighborsClassifier(n_neighbors=10, weights='distance')] | ||
else: | ||
raise ValueError('no supported ML model selected - choose between NuSVC or KNeighborsClassifier') | ||
|
||
print('chosen ML model is {}'.format(clfs[0])) | ||
|
||
return clfs |
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
Oops, something went wrong.