A Streamlit-based application that guides users through a 9-step ML workflow to build, train, and evaluate predictive models with optional AI-powered insights.
Transform raw data into actionable predictions through an intuitive step-by-step wizard. The app handles data loading, exploratory analysis, feature engineering, model training, and evaluationβall without requiring ML expertise.
- 9-Step Guided Workflow: Walk-through from data upload to model export
- AI-Powered Insights: Integrate with OpenAI, Groq, or Anthropic for smart recommendations
- Multiple Problem Types: Classification, Regression, and Time Series prediction
- Flexible Model Selection: Auto-selection or manual choice (Linear, Random Forest, XGBoost)
- Export Options: Download predictions, models, PDF reports, and JSON exports
- Run History: Manage and reload previous model training runs
- Data Quality Analysis: Automatic detection of issues and recommendations
AnyDataMLApp/
βββ app.py # Main Streamlit application
βββ requirements.txt # Python dependencies
βββ README.md # Documentation
βββ storage/ # Data and model storage
β βββ datasets/ # Uploaded dataset pickles
β βββ models/ # Trained model joblib files
β βββ predictions/ # Model predictions (CSV)
β βββ app.db # SQLite database for metadata
βββ utils/ # Core utility modules
β βββ __init__.py # Package exports
β βββ config.py # Configuration and constants
β βββ storage.py # Database operations
β βββ data_handler.py # Data loading and preprocessing
β βββ analysis.py # Data quality analysis
β βββ ml_pipeline.py # Model training orchestration
β βββ ai_handler.py # AI API integrations (OpenAI, Groq, Anthropic)
βββ .streamlit/
βββ config.toml # Streamlit configuration
βββ secrets.toml.example # Example secrets template
- Python 3.8 or higher
- pip (Python package manager)
-
Create a virtual environment (recommended)
python -m venv venv # Activate: # Windows: venv\Scripts\activate # macOS/Linux: source venv/bin/activate
-
Install dependencies
pip install -r requirements.txt
-
(Optional) Configure AI API Keys
- Copy
.streamlit/secrets.toml.exampleto.streamlit/secrets.toml - Add your API keys for AI features:
[openai] api_key = "sk-..." [groq] api_key = "gsk_..." [anthropic] api_key = "sk-ant-..."
- Never commit secrets.toml to version control
- Copy
streamlit run app.pyThe app opens at http://localhost:8501 (usually automatically)
| Step | Component | Purpose |
|---|---|---|
| 0 | Upload Data | Load CSV/Excel files, analyze structure |
| 1 | Select Target | Choose prediction target column |
| 2 | Problem Type | Classification, Regression, or Time Series |
| 3 | Feature Selection | Choose input features (auto-excludes target) |
| 4 | Feature Engineering | Configure preprocessing and transformations |
| 5 | Model Selection | Choose algorithm or use auto-selection |
| 6 | Train & Evaluate | Execute training pipeline with validation |
| 7 | Results & Insights | Analyze metrics, importance, and AI insights |
| 8 | Export & Download | Get predictions, models, and reports |
- Supports CSV and Excel formats
- Analyzes column types (numeric, categorical, datetime)
- Generates statistics and preview
- Stores metadata in SQLite database
- Select column to predict
- Optional: Specify business outcome for context
- Classification: Predicting categories/classes
- Regression: Predicting continuous values
- Time Series: Temporal prediction (auto-suggested for datetime targets)
- Multi-select features to use
- Target column automatically excluded
- Can select all, subset, or manually choose
Options:
βββ Missing Value Strategy: drop | mean | median | mode
βββ One-Hot Encode Categoricals: Yes/No
βββ Scale Numeric Features: Yes/No
βββ Extract DateTime Features: Yes/No
- Auto: Chooses based on problem type and data size
- Manual: Linear, Random Forest, or XGBoost
- Tailored recommendations based on data characteristics
- Pre-training validation checks
- Data quality report
- Model training with 80/20 train-test split
- Real-time progress updates
- Metrics: Accuracy, F1, MAE, RMSE, RΒ² (depending on problem type)
- Feature Importance: Top contributing features
- AI Insights (if API key configured):
- Model explanation
- Business recommendations
- Data quality insights
- Hyperparameter suggestions
- Predictions CSV (actual vs predicted)
- Serialized model (.joblib)
- PDF report with summary
- JSON export for integration
Enhance analysis with AI-powered recommendations. Requires API key from one of:
- Models: GPT-4, GPT-4 Turbo, GPT-3.5-Turbo
- Key Format:
sk-... - Setup: Get key from https://platform.openai.com/api-keys
- Models: Mixtral 8x7B, Llama 70B, Gemma 7B
- Key Format:
gsk_... - Setup: Register at https://console.groq.com
- Models: Claude Opus, Sonnet, Haiku
- Key Format:
sk-ant-... - Setup: Get key from https://console.anthropic.com
- Model Explanation - Plain English summary of model behavior
- Feature Suggestions - Ideas for feature engineering
- Model Recommendations - Smart algorithm selection
- Business Insights - Actionable recommendations
- Data Quality Report - Issues and solutions
- Hyperparameter Tuning - Optimal settings
- Logistic Regression (interpretable, fast)
- Random Forest (robust, handles non-linearity)
- XGBoost (high performance, slower training)
- Linear Regression (interpretable, simple)
- Random Forest (non-linear, feature interactions)
- XGBoost (state-of-the-art performance)
- Random Forest (baseline implementation)
- Supports datetime feature extraction
streamlit>=1.28.0
pandas>=2.0.0
numpy>=1.24.0
scikit-learn>=1.3.0
xgboost>=2.0.0
joblib>=1.3.0
openai>=1.0.0
groq>=0.4.0
anthropic>=0.7.0
openpyxl>=3.10.0
python-dotenv>=1.0.0
fpdf2>=2.7.0
matplotlib>=3.7.0
See requirements.txt for exact versions.
# Model availability
REGRESSION_MODELS = ["auto", "linear_regression", "random_forest", "xgboost"]
CLASSIFICATION_MODELS = ["auto", "logistic_regression", "random_forest", "xgboost"]
# Preprocessing options
MISSING_STRATEGIES = ["drop", "mean", "median", "mode"]
# Validation thresholds
MIN_ROWS_FOR_TRAINING = 10 # Minimum samples needed
HIGH_CARDINALITY_THRESHOLD = 50 # Flag high-cardinality categoricals
HIGH_NULL_PCT_THRESHOLD = 30 # Flag columns with >30% missing- 10 rows after preprocessing
- 1+ feature columns and 1 target column
- CSV or Excel format
- 100+ rows for reliable models
- Mix of features (numeric + categorical)
- <30% missing per column for best results
- Balanced classes for classification (avoid 1:100 ratio)
SQLite (storage/app.db) contains:
| Column | Type | Purpose |
|---|---|---|
| id | TEXT PK | Unique dataset ID |
| filename | TEXT | Original file name |
| rows, cols | INT | Data dimensions |
| columns | JSON | Column metadata & stats |
| preview | JSON | First 10 rows |
| created_at | TIMESTAMP | Upload time |
| Column | Type | Purpose |
|---|---|---|
| id | TEXT PK | Model run ID |
| dataset_id | TEXT FK | Associated dataset |
| target | TEXT | Prediction target |
| features | JSON | Selected features list |
| problem_type | TEXT | classification/regression/time_series |
| model_name | TEXT | Model used |
| metrics | JSON | Performance metrics |
| feature_importance | JSON | Feature rankings |
| created_at | TIMESTAMP | Training time |
- β
Store API keys in
.streamlit/secrets.toml - β
Add
secrets.tomlto.gitignore - β Use environment variables for deployment
- β Sanitize file uploads in production
β οΈ Models can execute codeβonly load trusted models
- Local storage (no cloud upload by default)
- Comply with GDPR/CCPA when using external APIs
- Consider data residency for sensitive data
- More rows dropped than expected due to missing values
- Fix: Use "mean" or "median" strategy instead of "drop"
- Feature was removed during preprocessing
- Fix: Check data quality report for high-missing or all-null columns
- Format mismatch or expired key
- Fix: Verify key format: OpenAI
sk-, Groqgsk_, Anthropicsk-ant-
- XGBoost on large datasets is computationally intensive
- Fix: Use Random Forest or reduce data size
- Model or predictions file missing from storage
- Fix: Retrain model or check filesystem permissions
import logging
logging.basicConfig(level=logging.DEBUG)| Scenario | Recommendation |
|---|---|
| Small data (<1K rows) | Random Forest (fast) |
| Large data (>10K rows) | XGBoost (accuracy) |
| Many missing values | Use "mean" strategy |
| High cardinality | Consider dimensionality reduction |
| Imbalanced classes | Check F1 score, not just accuracy |
- Update
config.pymodel list - Modify
pick_model()inml_pipeline.py - Test with sample data
- Implement in
step_8_export()inapp.py - Use
st.download_button()for download
- Create function in
ai_handler.py - Call unified
_call_ai_api()handler - Wire into appropriate step
| Error | Cause | Solution |
|---|---|---|
ModuleNotFoundError: streamlit |
Dependencies not installed | pip install -r requirements.txt |
Connection refused |
Port 8501 in use | streamlit run app.py --server.port 8502 |
PermissionError: storage/ |
No write access | Check directory permissions |
KeyError: 'target' |
Target not in DataFrame | Verify column name selected |
[Specify your license - MIT, Apache 2.0, etc.]
Built with Streamlit, Pandas, Scikit-learn, and XGBoost.
Version: 1.0.0
Last Updated: April 2026
Status: β
Production Ready
source venv/bin/activate # On Windows: venv\Scripts\activate
3. **Install Dependencies**
```bash
pip install -r requirements.txt
- (Optional) Add AI API Key
mkdir -p .streamlit
cp .streamlit/secrets.toml.example .streamlit/secrets.toml
# Edit .streamlit/secrets.toml with your API keySupported AI Providers:
- OpenAI:
sk-...prefix β https://platform.openai.com/ - Groq:
gsk_...prefix β https://console.groq.com/ (free tier) - Anthropic:
sk-ant-...prefix β https://console.anthropic.com/
streamlit run streamlit_app.pyVisit: http://localhost:8501
- Upload Data - CSV or Excel file
- Select Target - What to predict
- Problem Type - Classification / Regression / Time Series
- Feature Selection - Which columns to use
- Feature Engineering - Preprocessing options
- Model Selection - Choose or auto-select
- Train - Train the model
- Results - View metrics, features, AI insights
- Export - Download predictions, model, report
Add API key in sidebar (optional):
- Detects provider automatically
- Generates 6 types of insights
- Falls back to templates if unavailable
streamlit_app/
βββ streamlit_app.py # Main app (9-step UI)
βββ requirements.txt # Dependencies
βββ .streamlit/
β βββ config.toml # Streamlit config
β βββ secrets.toml.example # Example secrets
βββ utils/
β βββ config.py # Settings & constants
β βββ storage.py # SQLite operations
β βββ data_handler.py # Data loading/parsing
β βββ analysis.py # Data analysis
β βββ ml_pipeline.py # Model training/eval
β βββ ai_handler.py # AI insights
βββ storage/
βββ app.db # SQLite database
βββ datasets/ # Uploaded data
βββ models/ # Trained models
βββ predictions/ # Model outputs
- Push to GitHub
git add .
git commit -m "Initial commit"
git push- Deploy on Streamlit Cloud
- Visit: https://share.streamlit.io
- Connect GitHub repo
- Select
streamlit_app/streamlit_app.pyas entry point
- (Optional) Add Secrets
- In Streamlit Cloud dashboard β Manage app β Secrets
- Paste contents of
.streamlit/secrets.toml
| Provider | Cost | Free Tier | Notes |
|---|---|---|---|
| OpenAI | $0.0005/req (gpt-4o-mini) | No | Most capable |
| Groq | Free | 5K tokens/day | Fast inference |
| Anthropic | Pay as you go | No | High quality |
Edit utils/ai_handler.py:
def get_new_insight(data, provider, model, api_key):
# Implement for each provider (openai, groq, anthropic)
# Add fallback template function
passEdit utils/config.py:
REGRESSION_MODELS = ["auto", "linear_regression", "random_forest", "xgboost"]Then update utils/ml_pipeline.py pick_model() function.
- Re-upload data
- Check API key format (must start with correct prefix)
- Verify API key has credits/quota
- Check internet connection
- Ensure 10+ rows after preprocessing
- Check for missing values in target
- Try different missing value strategy
MIT
Issues? Check:
- Console output for error messages
.streamlit/config.tomlfor settings- API key format for AI features