Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
151 changes: 151 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
import streamlit as st
import os
import sys
from pathlib import Path

# Set page configuration first
st.set_page_config(
page_title="Analytics Dashboard",
page_icon="📊",
layout="wide"
)

# Add src directory and subdirectories to sys.path
project_root = Path(__file__).parent
src_path = project_root / 'src'
sys.path.insert(0, str(src_path))

# Add each application's directory to sys.path
app_dirs = ['DescriptiveAnalysis', 'PredictiveAnalytics1', 'preprocessing', 'PrescriptiveAnalysis1']
for app_dir in app_dirs:
app_path = src_path / app_dir
if app_path.exists():
sys.path.insert(0, str(app_path))
else:
print(f"Directory {app_dir} not found in src/. Please check the directory structure.")

# Add PredictiveAnalytics1/Frontend and PrescriptiveAnalysis1 subdirectories to sys.path
predictive_frontend_path = src_path / 'PredictiveAnalytics1' / 'Frontend'
if predictive_frontend_path.exists():
sys.path.insert(0, str(predictive_frontend_path))
else:
print(f"Frontend directory not found at {predictive_frontend_path}.")

prescriptive_frontend_path = src_path / 'PrescriptiveAnalysis1' / 'Frontend'
if prescriptive_frontend_path.exists():
sys.path.insert(0, str(prescriptive_frontend_path))
else:
print(f"Frontend directory not found at {prescriptive_frontend_path}.")

prescriptive_backend_path = src_path / 'PrescriptiveAnalysis1' / 'Backend'
if prescriptive_backend_path.exists():
sys.path.insert(0, str(prescriptive_backend_path))
else:
print(f"Backend directory not found at {prescriptive_backend_path}.")

# Import main functions from each application
try:
from DescriptiveAnalysis.frontend import main as descriptive_main
except ModuleNotFoundError as e:
print(f"Error importing DescriptiveAnalysis: {e}")
descriptive_main = None

try:
from PredictiveAnalytics1.Frontend.app import main as predictive_main
except ModuleNotFoundError as e:
print(f"Error importing PredictiveAnalytics1: {e}")
predictive_main = None

try:
from preprocessing.app import main as preprocessing_main
except ModuleNotFoundError as e:
print(f"Error importing preprocessing: {e}")
preprocessing_main = None

try:
from PrescriptiveAnalysis1.Frontend.main import main as prescriptive_main
except ModuleNotFoundError as e:
print(f"Error importing PrescriptiveAnalysis1: {e}")
prescriptive_main = None

# Custom CSS for styling
st.markdown("""
<style>
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;600&display=swap');

html, body {
font-family: 'Montserrat', sans-serif;
color: #333;
}
.sidebar .sidebar-content {
background: linear-gradient(135deg, #f0f4f8, #d9e2ec);
border-radius: 8px;
padding: 1rem;
}
.stSelectbox > div > label {
font-size: 1.1rem;
font-weight: 600;
color: #2c3e50;
}
.main-container {
background-color: #fff;
border-radius: 10px;
box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.1);
padding: 2rem;
margin: 1rem;
}
h1 {
color: #2c3e50;
text-align: center;
margin-bottom: 2rem;
}
</style>
""", unsafe_allow_html=True)

def main():
"""
Main function to run the Streamlit dashboard application.
Provides a sidebar to navigate between different analytics applications.
"""
st.title("Analytics Dashboard")

# Display import errors, if any
if descriptive_main is None:
st.error("Cannot import DescriptiveAnalysis. Please check the directory structure and files.")
if predictive_main is None:
st.error("Cannot import PredictiveAnalytics1. Please check the directory structure and files.")
if preprocessing_main is None:
st.error("Cannot import preprocessing. Please check the directory structure and files.")
if prescriptive_main is None:
st.error("Cannot import PrescriptiveAnalysis1. Please check the directory structure and files.")

# Sidebar for application selection
st.sidebar.title("Navigation")
app_options = [
"Descriptive Analysis",
"Predictive Analytics",
"Preprocessing",
"Prescriptive Analysis"
]
selected_app = st.sidebar.selectbox("Select Application", app_options)

# Map selected app to the corresponding main function
app_functions = {
"Descriptive Analysis": descriptive_main,
"Predictive Analytics": predictive_main,
"Preprocessing": preprocessing_main,
"Prescriptive Analysis": prescriptive_main
}

# Run the selected application's main function
with st.container():
st.markdown('<div class="main-container">', unsafe_allow_html=True)
selected_function = app_functions[selected_app]
if selected_function is None:
st.error(f"Cannot run {selected_app}. The module could not be imported. Please check the error messages above.")
else:
selected_function()
st.markdown('</div>', unsafe_allow_html=True)

if __name__ == "__main__":
main()
1 change: 1 addition & 0 deletions src/DescriptiveAnalysis/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

72 changes: 35 additions & 37 deletions src/DescriptiveAnalysis/frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,42 +5,7 @@
import streamlit.components.v1 as components
import pandas as pd

from backend import generate_data_cubes, process_download

# Set page configuration and custom CSS styling
st.set_page_config(layout="wide")

st.markdown("""
<style>
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;600&display=swap');

html, body {
background: linear-gradient(135deg, #f0f4f8, #d9e2ec);
font-family: 'Montserrat', sans-serif;
color: #333;
}
.main-container {
background-color: #fff;
border-radius: 10px;
box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.1);
padding: 2rem;
margin: 1rem;
}
.css-1e5imcs, .css-1d391kg {
background-color: #ffffff !important;
border-radius: 8px;
box-shadow: 0px 2px 5px rgba(0,0,0,0.1);
padding: 1rem;
}
.css-1aumxhk {
font-size: 1.2rem;
font-weight: 600;
}
.css-1d391kg .stTabs {
background-color: #fff;
}
</style>
""", unsafe_allow_html=True)
from .backend import generate_data_cubes, process_download

def load_data():
"""
Expand Down Expand Up @@ -347,6 +312,39 @@ def main():
2. Drill-Down and Roll-Up
3. Batch Processing
"""
# Apply custom CSS styling
st.markdown("""
<style>
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;600&display=swap');

html, body {
background: linear-gradient(135deg, #f0f4f8, #d9e2ec);
font-family: 'Montserrat', sans-serif;
color: #333;
}
.main-container {
background-color: #fff;
border-radius: 10px;
box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.1);
padding: 2rem;
margin: 1rem;
}
.css-1e5imcs, .css-1d391kg {
background-color: #ffffff !important;
border-radius: 8px;
box-shadow: 0px 2px 5px rgba(0,0,0,0.1);
padding: 1rem;
}
.css-1aumxhk {
font-size: 1.2rem;
font-weight: 600;
}
.css-1d391kg .stTabs {
background-color: #fff;
}
</style>
""", unsafe_allow_html=True)

st.title("Data Warehouse & Cube Generator")

# Load data from CSV file
Expand Down Expand Up @@ -387,4 +385,4 @@ def main():
batch_processing()

if __name__ == "__main__":
main()
main()
1 change: 1 addition & 0 deletions src/PredictiveAnalytics1/Backend/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions src/PredictiveAnalytics1/Frontend/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

17 changes: 6 additions & 11 deletions src/PredictiveAnalytics1/Frontend/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,13 @@
import pandas as pd
import numpy as np
import os
import sys
from pathlib import Path
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
from Backend.backend import (
load_data, preprocess_data, apply_pca, determine_problem_type, train_model)
from ..Backend.backend import load_data, preprocess_data, apply_pca, determine_problem_type, train_model
from sklearn.preprocessing import LabelEncoder
from sklearn.cluster import DBSCAN, SpectralClustering
from sklearn.preprocessing import StandardScaler
from sklearn.metrics import silhouette_score


st.set_page_config(page_title="Model Comparison Tool", layout="wide")


@st.cache_data
def cached_load_data(file_path):
return load_data(file_path)
Expand Down Expand Up @@ -127,7 +120,11 @@ def main():
else:
current_file = Path(__file__).resolve()
dataset_dir = current_file.parents[3] / 'Datasets' / 'predictive-analytics-1'
dataset_files = [f for f in os.listdir(dataset_dir) if f.endswith(".csv")]
if not dataset_dir.exists():
st.warning("Dataset directory not found. Please upload a CSV file.")
dataset_files = []
else:
dataset_files = [f for f in os.listdir(dataset_dir) if f.endswith(".csv")]

if dataset_files:
selected_dataset = st.selectbox("Select a dataset", dataset_files)
Expand Down Expand Up @@ -267,13 +264,11 @@ def main():

st.dataframe(comparison_df.set_index('Model').T)


st.subheader("Performance Visualization")
chart_data = comparison_df.melt(id_vars=['Model'], var_name='Metric', value_name='Score')
chart_data['Score'] = pd.to_numeric(chart_data['Score'], errors='coerce')
chart_data = chart_data.dropna(subset=['Score'])


if not chart_data.empty:
st.bar_chart(chart_data, x='Metric', y='Score', color='Model', stack=False)
else:
Expand Down
1 change: 1 addition & 0 deletions src/PredictiveAnalytics1/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions src/PrescriptiveAnalysis1/Backend/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions src/PrescriptiveAnalysis1/Frontend/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

18 changes: 9 additions & 9 deletions src/PrescriptiveAnalysis1/Frontend/main.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import streamlit as st
import sys
import os
import pandas as pd
import os
import time
from collections import defaultdict
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
from Backend.gspan import run_gspan_analysis, construct_dfs_code, load_graphs_from_json
from Backend.apriori_graph import parse_graph_file, apriori_graph_mining
from Backend.gsp import preprocess_sequences_ordered, gsp_algorithm
from Backend.apriori import run_apriori_analysis
from Backend.fp_growth import run_fp_growth_analysis

# Relative imports for Backend modules
from ..Backend.gspan import run_gspan_analysis, construct_dfs_code, load_graphs_from_json
from ..Backend.apriori_graph import parse_graph_file, apriori_graph_mining
from ..Backend.gsp import preprocess_sequences_ordered, gsp_algorithm
from ..Backend.apriori import run_apriori_analysis
from ..Backend.fp_growth import run_fp_growth_analysis

def apriori_graph_mining_app():
st.title("Apriori-Based Graph Mining")
uploaded_file = st.file_uploader("Upload your graph dataset file ", type=['txt'], key="apriori_file")
uploaded_file = st.file_uploader("Upload your graph dataset file", type=['txt'], key="apriori_file")
if uploaded_file is not None:
graphs = parse_graph_file(uploaded_file)
st.write(f"Number of graphs loaded: {len(graphs)}")
Expand Down
1 change: 1 addition & 0 deletions src/PrescriptiveAnalysis1/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions src/preprocessing/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Loading