Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Pulse Predict
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Furkan Erbilgin
Pulse Predict
Commits
36c89ad4
Commit
36c89ad4
authored
6 months ago
by
Lizi Brelidze
Browse files
Options
Downloads
Patches
Plain Diff
graph on bitcoin
parent
95c7781b
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
app.py
+12
-6
12 additions, 6 deletions
app.py
templates/dashboard.html
+1
-1
1 addition, 1 deletion
templates/dashboard.html
with
13 additions
and
7 deletions
app.py
+
12
−
6
View file @
36c89ad4
...
...
@@ -128,7 +128,8 @@ def index():
df_prophet_with_date
[
'
ds_date
'
]
=
df_prophet_with_date
[
'
ds
'
].
dt
.
normalize
()
temp_merged
=
pd
.
merge
(
df_prophet_with_date
,
df_fng
,
on
=
'
ds_date
'
,
how
=
'
left
'
)
temp_merged
[
'
fear_greed
'
]
=
temp_merged
[
'
fear_greed
'
].
ffill
().
bfill
()
temp_merged
[
'
fear_greed
'
].
fillna
(
50
,
inplace
=
True
)
# Final fallback
# FIX for Pandas FutureWarning: Use direct assignment instead of inplace=True on potentially chained access
temp_merged
[
'
fear_greed
'
]
=
temp_merged
[
'
fear_greed
'
].
fillna
(
50
)
# Final fallback
df_merged
=
temp_merged
[[
'
ds
'
,
'
y
'
,
'
volume
'
,
'
fear_greed
'
]].
copy
()
fng_available
=
True
data_confidence_score
+=
25
...
...
@@ -156,21 +157,25 @@ def index():
try
:
print
(
"
--- Instantiating Prophet model ---
"
)
model
=
Prophet
(
interval_width
=
0.95
)
# 95% prediction interval
volume_regressor_added
=
False
# <<< FIX: Initialize flag
fng_regressor_added
=
False
# <<< FIX: Initialize flag
print
(
"
--- Adding Regressors ---
"
)
# Add 'volume' regressor if valid
if
'
volume
'
in
df_merged
.
columns
and
df_merged
[
'
volume
'
].
notna
().
any
():
model
.
add_regressor
(
'
volume
'
)
volume_regressor_added
=
True
# <<< FIX: Set flag
print
(
"
Added
'
volume
'
regressor.
"
)
else
:
print
(
"
--- Skipping
'
volume
'
regressor (column missing or all NaN) ---
"
)
# Add 'fear_greed' regressor if valid and available
if
fng_available
and
'
fear_greed
'
in
df_merged
.
columns
and
df_merged
[
'
fear_greed
'
].
notna
().
any
():
model
.
add_regressor
(
'
fear_greed
'
)
fng_regressor_added
=
True
# <<< FIX: Set flag
print
(
"
Added
'
fear_greed
'
regressor.
"
)
else
:
fng_available
=
False
# Ensure state consistency
print
(
"
Fitting model WITHOUT
'
fear_greed
'
regressor (not available or all NaN).
"
)
fng_available
=
False
# Final check on data points before fitting
df_merged
.
dropna
(
subset
=
[
'
y
'
],
inplace
=
True
)
# Drop rows if 'y' became NaN
...
...
@@ -184,12 +189,14 @@ def index():
future
=
model
.
make_future_dataframe
(
periods
=
24
,
freq
=
'
h
'
)
print
(
"
--- Populating future regressor values... ---
"
)
if
'
volume
'
in
model
.
regressors
:
# <<< FIX: Use flags instead of checking model.regressors >>>
if
volume_regressor_added
:
last_volume
=
df_merged
[
'
volume
'
].
iloc
[
-
1
]
if
not
df_merged
[
'
volume
'
].
empty
else
0
future
[
'
volume
'
]
=
last_volume
print
(
f
"
- Set future
'
volume
'
to:
{
last_volume
}
"
)
if
'
fear_greed
'
in
model
.
regressors
:
# <<< FIX: Use flags instead of checking model.regressors >>>
if
fng_regressor_added
:
if
current_fng_value
is
not
None
and
pd
.
notna
(
current_fng_value
):
future
[
'
fear_greed
'
]
=
float
(
current_fng_value
)
used_current_fng_for_future
=
True
...
...
@@ -376,4 +383,3 @@ if __name__ == '__main__':
# Port 5000 is default, change if needed
# Debug=True provides more error detail and auto-reloads on code changes
app
.
run
(
debug
=
True
,
host
=
'
0.0.0.0
'
,
port
=
5000
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
templates/dashboard.html
+
1
−
1
View file @
36c89ad4
...
...
@@ -181,7 +181,7 @@
}
// Chart Rendering
const
plotData
=
{{
plot_data
|
tojson
|
safe
}};
// Embed data from Flask
const
plotData
=
JSON
.
parse
(
'
{{ plot_data | tojson | safe }}
'
)
;
// Embed data from Flask
const
chartCanvas
=
document
.
getElementById
(
'
priceChart
'
);
if
(
plotData
&&
plotData
.
labels
&&
plotData
.
labels
.
length
>
0
&&
chartCanvas
)
{
...
...
...
...
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
sign in
to comment