Skip to content

Commit

Permalink
Add days to predict input box
Browse files Browse the repository at this point in the history
  • Loading branch information
mariamills committed Nov 14, 2023
1 parent d5048d5 commit 1e2c4ed
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 15 deletions.
21 changes: 11 additions & 10 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,6 @@ def get_data():
return jsonify(filtered_df.to_dict(orient='list'))


# Fetch number of days to forecast
@app.route('/forecast', methods=['POST'])
def get_forecast_days():
global num_steps
num_steps = request.json['days']
# convert to int
num_steps = int(num_steps)
return jsonify(num_steps)


# Fetch Data and Plot
@app.route('/plot', methods=['POST'])
def plot():
Expand Down Expand Up @@ -178,6 +168,17 @@ def plot():
'legend_url': 'data:image/png;base64,{}'.format(legend_url)})



# Fetch number of days to forecast
@app.route('/forecast', methods=['POST'])
def get_forecast_days():
global num_steps
num_steps = request.json['days']
# convert to int
num_steps = int(num_steps)
return jsonify(num_steps)


@app.route('/data_explorer')
def data_explorer():
return render_template('data_explorer.html')
Expand Down
6 changes: 1 addition & 5 deletions static/js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const modelType = document.getElementById('model-type')
const dataDropdownSelection = document.getElementById('dataset')
const daysToForecast = document.getElementById('days-to-forecast')


// Listen for click events on the mobile menu button
if (mobileMenuButton) {
mobileMenuButton.addEventListener("click", function () {
Expand All @@ -22,7 +23,6 @@ if (mobileMenuButton) {
});
}


// Get selected features
function getSelectedFeatures() {
const checkboxes = document.querySelectorAll('input[name="feature"]:checked');
Expand All @@ -34,7 +34,6 @@ function getSelectedFeatures() {
return selected;
}


// Fetch features and create checkboxes
function createFeatureCheckboxes(features) {
// Check if features is an array
Expand Down Expand Up @@ -85,7 +84,6 @@ function createFeatureCheckboxes(features) {
console.log('Checkboxes created for features:', features); // Debugging line
}


// Initial fetch of features when the page loads
fetch('/features', {
method: 'GET'
Expand All @@ -101,8 +99,6 @@ fetch('/features', {
})
.catch(error => console.error('Error:', error));



// When a new model is selected, fetch the new model's features
if (modelType) {
modelType.addEventListener('change', () => {
Expand Down
Binary file modified static/plots/arima-future-forecast-plot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified static/plots/prophet-future-forecast-plot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 1e2c4ed

Please sign in to comment.