Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
MLAir
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
esde
machine-learning
MLAir
Commits
1c22331b
Commit
1c22331b
authored
4 years ago
by
leufen1
Browse files
Options
Downloads
Patches
Plain Diff
added description, /close
#275
parent
23e65242
No related branches found
No related tags found
3 merge requests
!253
include current develop
,
!252
Resolve "release v1.3.0"
,
!241
Resolve "add box-cox transformation to default data handler and statistics"
Pipeline
#60283
passed
4 years ago
Stage: test
Stage: docs
Stage: pages
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
mlair/helpers/statistics.py
+31
-4
31 additions, 4 deletions
mlair/helpers/statistics.py
with
31 additions
and
4 deletions
mlair/helpers/statistics.py
+
31
−
4
View file @
1c22331b
...
...
@@ -155,20 +155,47 @@ def min_max_apply(data: Data, min: Data, max: Data) -> Data:
def
log
(
data
:
Data
,
dim
:
Union
[
str
,
int
])
->
Tuple
[
Data
,
Dict
[(
str
,
Data
)]]:
"""
Apply logarithmic transformation (and standarization) to data. This method first uses the logarithm for
transformation and second applies the `standardise` method additionally. A logarithmic function numpy
'
s log1p is
used (`res = log(1+x)`) instead of the pure logarithm to be applicable to values of 0 too.
:param data: transform this data
:param dim: name (xarray) or axis (pandas) of dimension which should be transformed
:return: transformed data, and option dictionary with keys method, mean, and std
"""
transformed_standardized
,
opts
=
standardise
(
np
.
log1p
(
data
),
dim
)
opts
.
update
({
"
method
"
:
"
log
"
})
return
transformed_standardized
,
opts
def
log_apply
(
data
:
Data
,
mean
:
Data
,
std
:
Data
)
->
Data
:
return
standardise_apply
(
np
.
log1p
(
data
),
mean
,
std
)
def
log_inverse
(
data
:
Data
,
mean
:
Data
,
std
:
Data
)
->
Data
:
"""
Apply inverse log transformation (therefore exponential transformation). Because `log` is using `np.log1p` this
method is based on the equivalent method `np.exp1m`. Data are first rescaled using `standardise_inverse` and then
given to the exponential function.
:param data: apply inverse log transformation on this data
:param mean: mean of the standarization
:param std: std of the standarization
:return: inverted data
"""
data_rescaled
=
standardise_inverse
(
data
,
mean
,
std
)
return
np
.
expm1
(
data_rescaled
)
def
log_apply
(
data
:
Data
,
mean
:
Data
,
std
:
Data
)
->
Data
:
"""
Apply numpy
'
s log1p on given data. Further information can be found in description of `log` method.
:param data: transform this data
:param mean: mean of the standarization
:param std: std of the standarization
:return: transformed data
"""
return
standardise_apply
(
np
.
log1p
(
data
),
mean
,
std
)
def
mean_squared_error
(
a
,
b
):
"""
Calculate mean squared error.
"""
return
np
.
square
(
a
-
b
).
mean
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment