Spaces:
Sleeping
Sleeping
File size: 7,367 Bytes
00b00eb |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 |
###########################################################################################################
# Default
###########################################################################################################
import pandas as pd
from collections import OrderedDict
# default_dct
default_dct = {
"data_import": {
"gold_layer_df": pd.DataFrame(),
"granularity_selection": "daily",
"dashboard_df": None,
"tool_df": None,
"unique_panels": [],
"imputation_df": None,
"imputed_tool_df": None,
"group_dict": {},
"category_dict": {},
},
"data_validation": {
"target_column": 0,
"selected_panels": None,
"selected_feature": 0,
"validated_variables": [],
"Non_media_variables": 0,
"correlation": [],
},
"transformations": {
"final_df": None,
"summary_string": None,
"Media": {},
"Exogenous": {},
"Internal": {},
"Specific": {},
"correlation_plot_selection": [],
},
"model_build": {
"sel_target_col": None,
"all_iters_check": False,
"iterations": 0,
"build_button": False,
"show_results_check": False,
"session_state_saved": {},
},
"model_tuning": {
"sel_target_col": None,
"sel_model": {},
"flag_expander": False,
"start_date_default": None,
"end_date_default": None,
"repeat_default": "No",
"flags": {},
"select_all_flags_check": {},
"selected_flags": {},
"trend_check": False,
"week_num_check": False,
"sine_cosine_check": False,
"session_state_saved": {},
},
"saved_model_results": {
"selected_options": None,
"model_grid_sel": [1],
},
"current_media_performance": {
"model_outputs": {},
},
"media_performance": {"start_date": None, "end_date": None},
"response_curves": {
"original_metadata_file": None,
"modified_metadata_file": None,
},
"scenario_planner": {
"original_metadata_file": None,
"modified_metadata_file": None,
},
"saved_scenarios": {"saved_scenarios_dict": OrderedDict()},
"optimized_result_analysis": {
"selected_scenario_selectbox_visualize": 0,
"metric_selectbox_visualize": 0,
},
}
###########################################################################################################
# Data Import
###########################################################################################################
# Constants Data Import
upload_rows_limit = 1000000 # Maximum number of rows allowed for upload
upload_column_limit = 1000 # Maximum number of columns allowed for upload
word_length_limit_lower = 2 # Minimum allowed length for words
word_length_limit_upper = 100 # Maximum allowed length for words
minimum_percent_overlap = (
1 # Minimum required percentage of overlap with the reference data
)
minimum_row_req = 30 # Minimum number of rows required
percent_drop_col_threshold = 50 # Percentage threshold above which columns are automatically categorized for drop imputation
###########################################################################################################
# Transfromations
###########################################################################################################
# Constants Transformations
predefined_defaults = {
"Lag": (1, 2),
"Lead": (1, 2),
"Moving Average": (1, 2),
"Saturation": (10, 20),
"Power": (2, 4),
"Adstock": (0.5, 0.7),
} # Pre-defined default values of every transformation
# Transfromations min, max and step
lead_min_value = 1
lead_max_value = 10
lead_step = 1
lag_min_value = 1
lag_max_value = 10
lag_step = 1
moving_average_min_value = 1
moving_average_max_value = 10
moving_average_step = 1
saturation_min_value = 0
saturation_max_value = 100
saturation_step = 1
power_min_value = 1
power_max_value = 5
power_step = 1
adstock_min_value = 0.0
adstock_max_value = 1.0
adstock_step = 0.05
display_max_col = 500 # Maximum columns to display
###########################################################################################################
# Model Build
###########################################################################################################
MAX_COMBINATIONS = 50000 # Max number of model combinations possible
MIN_MODEL_NAME_LENGTH = 0 # model can only be saved if len(model_name) is greater than this value
MIN_P_VALUE_THRESHOLD = 0.06 # coefficients with p values less than this value are considered valid
MODEL_POS_COEFF_RATIO_THRESHOLD = 0 # ratio of positive coefficients/total coefficients for model validity
MODEL_P_VALUE_RATIO_THRESHOLD = 0 # ratio of coefficients with p value/total coefficients for model validity
MAX_TOP_FEATURES = 5 # max number of top features selected per variable
MAX_NUM_FILTERS = 10 # maximum number of filters allowed
DEFAULT_FILTER_VALUE = 0.0 # default value of a new filter
VIF_LOW_THRESHOLD = 3 # Threshold for VIF to be colored green
VIF_HIGH_THRESHOLD = 10 # Threshold for VIF to be colored red
DEFAULT_TRAIN_RATIO = 3/4 # default train set ratio (75%)
###########################################################################################################
# Model Tuning
###########################################################################################################
import numpy as np
NUM_FLAG_COLS_TO_DISPLAY = 4 # Number of columns to be created on UI to display flags
HALF_YEAR_THRESHOLD = 6 # Threshold of months to create quarter frequency sine-cosine waves
FULL_YEAR_THRESHOLD = 12 # Threshold of months to create quarter annual sine-cosine waves
TREND_MIN = 5 # Starting value of trend line
ANNUAL_FREQUENCY = 2 * np.pi / 365 # annual frequency
QTR_FREQUENCY_FACTOR = 4 # multiplication factor to get quarterly frequency
HALF_YEARLY_FREQUENCY_FACTOR = 2 # multiplication factor to get semi-annual frequency
###########################################################################################################
# Scenario Planner
###########################################################################################################
# Constants Scenario Planner
xtol_tolerance_per = 1 # Percenatge of tolerance
mroi_threshold = 0.05 # mROI threshold
word_length_limit_lower = 2 # Minimum allowed length for words
word_length_limit_upper = 100 # Maximum allowed length for words
###########################################################################################################
# PPT utils
###########################################################################################################
TITLE_FONT_SIZE = 20
AXIS_LABEL_FONT_SIZE = 8
CHART_TITLE_FONT_SIZE = 14
AXIS_TITLE_FONT_SIZE = 12
DATA_LABEL_FONT_SIZE = 8
LEGEND_FONT_SIZE = 10
PIE_LEGEND_FONT_SIZE = 7
###########################################################################################################
# Page Name
###########################################################################################################
|