Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mppt-level-training
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
aakash.bedi
mppt-level-training
Commits
91322ba4
Commit
91322ba4
authored
Mar 07, 2023
by
aakash.bedi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated destructors
parent
b16a85d1
Pipeline
#59985
failed with stage
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
89 additions
and
64 deletions
+89
-64
scripts/core/engine/ml_modelling.py
scripts/core/engine/ml_modelling.py
+89
-64
No files found.
scripts/core/engine/ml_modelling.py
View file @
91322ba4
...
@@ -19,74 +19,99 @@ class AiModelling:
...
@@ -19,74 +19,99 @@ class AiModelling:
for
inv_id
in
list
(
self
.
df_raw_tags
[
'inv_id'
]
.
unique
()):
for
inv_id
in
list
(
self
.
df_raw_tags
[
'inv_id'
]
.
unique
()):
df
=
self
.
df_raw_tags
[
self
.
df_raw_tags
[
'inv_id'
]
==
inv_id
]
df
=
self
.
df_raw_tags
[
self
.
df_raw_tags
[
'inv_id'
]
==
inv_id
]
for
mppt_id
in
list
(
self
.
df_raw_tags
[
'mppt_id'
]
.
unique
()):
for
mppt_id
in
list
(
self
.
df_raw_tags
[
'mppt_id'
]
.
unique
()):
print
(
f
'1st memory allocation for {inv_id} & {mppt_id} - {tracemalloc.get_traced_memory()}'
)
print
(
f
'memory allocation for {inv_id} & {mppt_id} - {tracemalloc.get_traced_memory()}'
)
gc
.
collect
()
data_modelling
=
DataModelling
(
start_timestamp
=
self
.
start_timestamp
,
tracemalloc
.
reset_peak
()
end_timestamp
=
self
.
end_timestamp
,
print
(
f
'2nd memory allocation for {inv_id} & {mppt_id} - {tracemalloc.get_traced_memory()}'
)
df_coefficients
=
self
.
df_coefficients
)
tracemalloc
.
clear_traces
()
data_modelling
.
get_data
(
inv_id
=
inv_id
,
mppt_id
=
mppt_id
,
df
=
df
)
print
(
f
'3rd memory allocation for {inv_id} & {mppt_id} - {tracemalloc.get_traced_memory()}'
)
del
data_modelling
df_mppt_level
=
df
[
df
[
'mppt_id'
]
==
mppt_id
]
except
Exception
as
e
:
df_kairos_data
=
get_tags_data
(
df_input_tags
=
df_mppt_level
,
start_timestamp
=
self
.
start_timestamp
,
logger
.
exception
(
f
'Exception - {e}'
)
end_timestamp
=
self
.
end_timestamp
,
inv_id
=
inv_id
,
mppt_id
=
mppt_id
)
def
__del__
(
self
):
print
(
f
'4th memory allocation for {inv_id} & {mppt_id} - {tracemalloc.get_traced_memory()}'
)
try
:
gc
.
collect
()
print
(
'destructor called, AiModelling die!'
)
tracemalloc
.
reset_peak
()
except
Exception
as
e
:
print
(
f
'5th memory allocation for {inv_id} & {mppt_id} - {tracemalloc.get_traced_memory()}'
)
logger
.
exception
(
f
'Exception - {e}'
)
tracemalloc
.
clear_traces
()
print
(
f
'6th memory allocation for {inv_id} & {mppt_id} - {tracemalloc.get_traced_memory()}'
)
class
DataModelling
:
logger
.
info
(
f
'Shape of final df - {df_kairos_data.shape}'
)
def
__init__
(
self
,
start_timestamp
,
end_timestamp
,
df_coefficients
):
self
.
start_timestamp
=
start_timestamp
mppt_data
=
GetData
()
self
.
end_timestamp
=
end_timestamp
df_mppt
=
mppt_data
.
associate_inv_mppt_id
(
df
=
df_kairos_data
)
self
.
df_coefficients
=
df_coefficients
print
(
f
'7th memory allocation for {inv_id} & {mppt_id} - {tracemalloc.get_traced_memory()}'
)
def
get_data
(
self
,
inv_id
,
mppt_id
,
df
):
gc
.
collect
()
try
:
tracemalloc
.
reset_peak
()
print
(
f
'1st memory allocation for {inv_id} & {mppt_id} - {tracemalloc.get_traced_memory()}'
)
print
(
f
'8th memory allocation for {inv_id} & {mppt_id} - {tracemalloc.get_traced_memory()}'
)
gc
.
collect
()
tracemalloc
.
clear_traces
()
tracemalloc
.
reset_peak
()
print
(
f
'9th memory allocation for {inv_id} & {mppt_id} - {tracemalloc.get_traced_memory()}'
)
print
(
f
'2nd memory allocation for {inv_id} & {mppt_id} - {tracemalloc.get_traced_memory()}'
)
tracemalloc
.
clear_traces
()
df_coefficient_multiply
=
mppt_data
.
multiply_mppt_coefficients
(
df_mppt
=
df_mppt
,
print
(
f
'3rd memory allocation for {inv_id} & {mppt_id} - {tracemalloc.get_traced_memory()}'
)
df_coefficients
=
self
.
df_coefficients
)
df_mppt_level
=
df
[
df
[
'mppt_id'
]
==
mppt_id
]
print
(
f
'10th memory allocation for {inv_id} & {mppt_id} - {tracemalloc.get_traced_memory()}'
)
df_kairos_data
=
get_tags_data
(
df_input_tags
=
df_mppt_level
,
start_timestamp
=
self
.
start_timestamp
,
gc
.
collect
()
end_timestamp
=
self
.
end_timestamp
,
inv_id
=
inv_id
,
mppt_id
=
mppt_id
)
tracemalloc
.
reset_peak
()
print
(
f
'11th memory allocation for {inv_id} & {mppt_id} - {tracemalloc.get_traced_memory()}'
)
print
(
f
'4th memory allocation for {inv_id} & {mppt_id} - {tracemalloc.get_traced_memory()}'
)
tracemalloc
.
clear_traces
()
gc
.
collect
()
print
(
f
'12th memory allocation for {inv_id} & {mppt_id} - {tracemalloc.get_traced_memory()}'
)
tracemalloc
.
reset_peak
()
print
(
f
'5th memory allocation for {inv_id} & {mppt_id} - {tracemalloc.get_traced_memory()}'
)
data_preprocessing
=
DataPreprocessing
()
tracemalloc
.
clear_traces
()
df_clean
=
data_preprocessing
.
remove_outliers
(
df
=
df_coefficient_multiply
,
print
(
f
'6th memory allocation for {inv_id} & {mppt_id} - {tracemalloc.get_traced_memory()}'
)
param_list
=
[
'tilt_irradiance'
,
'voltage_mppt'
,
'current_mppt'
])
logger
.
info
(
f
'Shape of final df - {df_kairos_data.shape}'
)
print
(
f
'13th memory allocation for {inv_id} & {mppt_id} - {tracemalloc.get_traced_memory()}'
)
gc
.
collect
()
mppt_data
=
GetData
()
tracemalloc
.
reset_peak
()
df_mppt
=
mppt_data
.
associate_inv_mppt_id
(
df
=
df_kairos_data
)
print
(
f
'14th memory allocation for {inv_id} & {mppt_id} - {tracemalloc.get_traced_memory()}'
)
tracemalloc
.
clear_traces
()
print
(
f
'7th memory allocation for {inv_id} & {mppt_id} - {tracemalloc.get_traced_memory()}'
)
print
(
f
'15th memory allocation for {inv_id} & {mppt_id} - {tracemalloc.get_traced_memory()}'
)
gc
.
collect
()
tracemalloc
.
reset_peak
()
Training
(
df
=
df_clean
)
.
data_training
(
inv_id
=
inv_id
,
mppt_id
=
mppt_id
)
print
(
f
'8th memory allocation for {inv_id} & {mppt_id} - {tracemalloc.get_traced_memory()}'
)
tracemalloc
.
clear_traces
()
del
df_kairos_data
print
(
f
'9th memory allocation for {inv_id} & {mppt_id} - {tracemalloc.get_traced_memory()}'
)
del
df_mppt
del
df_coefficient_multiply
df_coefficient_multiply
=
mppt_data
.
multiply_mppt_coefficients
(
df_mppt
=
df_mppt
,
df_coefficients
=
self
.
df_coefficients
)
print
(
f
'16th memory allocation for {inv_id} & {mppt_id} - {tracemalloc.get_traced_memory()}'
)
gc
.
collect
()
print
(
f
'10th memory allocation for {inv_id} & {mppt_id} - {tracemalloc.get_traced_memory()}'
)
tracemalloc
.
reset_peak
()
gc
.
collect
()
print
(
f
'17th memory allocation for {inv_id} & {mppt_id} - {tracemalloc.get_traced_memory()}'
)
tracemalloc
.
reset_peak
()
tracemalloc
.
clear_traces
()
print
(
f
'11th memory allocation for {inv_id} & {mppt_id} - {tracemalloc.get_traced_memory()}'
)
print
(
f
'18th memory allocation for {inv_id} & {mppt_id} - {tracemalloc.get_traced_memory()}'
)
tracemalloc
.
clear_traces
()
print
(
f
'12th memory allocation for {inv_id} & {mppt_id} - {tracemalloc.get_traced_memory()}'
)
data_preprocessing
=
DataPreprocessing
()
df_clean
=
data_preprocessing
.
remove_outliers
(
df
=
df_coefficient_multiply
,
param_list
=
[
'tilt_irradiance'
,
'voltage_mppt'
,
'current_mppt'
])
print
(
f
'13th memory allocation for {inv_id} & {mppt_id} - {tracemalloc.get_traced_memory()}'
)
gc
.
collect
()
tracemalloc
.
reset_peak
()
print
(
f
'14th memory allocation for {inv_id} & {mppt_id} - {tracemalloc.get_traced_memory()}'
)
tracemalloc
.
clear_traces
()
print
(
f
'15th memory allocation for {inv_id} & {mppt_id} - {tracemalloc.get_traced_memory()}'
)
Training
(
df
=
df_clean
)
.
data_training
(
inv_id
=
inv_id
,
mppt_id
=
mppt_id
)
del
df_kairos_data
del
df_mppt
del
df_coefficient_multiply
print
(
f
'16th memory allocation for {inv_id} & {mppt_id} - {tracemalloc.get_traced_memory()}'
)
gc
.
collect
()
tracemalloc
.
reset_peak
()
print
(
f
'17th memory allocation for {inv_id} & {mppt_id} - {tracemalloc.get_traced_memory()}'
)
tracemalloc
.
clear_traces
()
print
(
f
'18th memory allocation for {inv_id} & {mppt_id} - {tracemalloc.get_traced_memory()}'
)
except
Exception
as
e
:
except
Exception
as
e
:
logger
.
exception
(
f
'Exception - {e}'
)
logger
.
exception
(
f
'Exception - {e}'
)
def
__del__
(
self
):
def
__del__
(
self
):
try
:
try
:
print
(
'destructor called, die!'
)
print
(
'destructor called,
DataModelling
die!'
)
except
Exception
as
e
:
except
Exception
as
e
:
logger
.
exception
(
f
'Exception - {e}'
)
logger
.
exception
(
f
'Exception - {e}'
)
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment