Skip to content

Lab · Master's in Applied AI · Tecnológico de Monterrey

From Raw Data to Model: An End-to-End Data Science Pipeline in Python

A series of eight labs from the Master's in Applied Artificial Intelligence at Tecnológico de Monterrey, course TC5053 – Data Science and Analytics (April to July 2026). Each one tackles a different problem with a public dataset, and together they cover the full cycle: extraction with pandas and SQL, exploratory analysis, preprocessing, feature engineering, dimensionality reduction, and regression models built as scikit-learn pipelines. The best models reached an R² of 0.963 predicting diamond prices and 97.4% accuracy classifying tumors, with no false positives.

My role

I completed the pandas, SQL, exploratory analysis and preprocessing labs (1 to 4) individually. The feature engineering, PCA and regression labs (5 to 8) were developed in a three-person team; the PCA lab was submitted from my repository. All of them received the top grade.

Problems and data

Each lab practices one stage of the cycle with a different public dataset:

LabTopicData
1Data analysis with pandas2020 weather data from a Max Planck Institute station (Kaggle)
2Database access and SQLRelational database of Netflix engagement and top 10 (MySQL)
3Exploratory data analysis (EDA)Bank customers and personal loans (Kaggle)
4PreprocessingHeart disease patients (Kaggle)
5Feature engineeringComputer specifications and prices (Kaggle)
6Dimensionality reduction (PCA)Automobile specifications (UCI)
7Linear regressionDiamond prices (ggplot2)
8Logistic regressionBreast tumors (UCI)

The data science cycle

flowchart LR
    accTitle: Data science cycle
    accDescr: Data is extracted from CSV files and a MySQL database, goes through exploratory analysis, preprocessing, feature engineering and PCA, and ends in linear and logistic regression models evaluated with metrics.
    A[(CSV and MySQL)] --> B[Extraction with pandas and SQL]
    B --> C[Exploratory analysis]
    C --> D[Preprocessing]
    D --> E[Feature engineering]
    E --> F[PCA]
    F --> G["scikit-learn pipelines"]
    G --> H[Linear regression]
    G --> I[Logistic regression]
    H --> J[Evaluation with metrics]
    I --> J
Figure 1. Each lab covers one stage; the last ones chain preprocessing and the model into a single pipeline.

Process

  1. Extraction and cleaningLoading data with pandas (types, dates, aggregations) and SQL queries with joins against a MySQL database via SQLAlchemy.
  2. ExplorationDistributions, correlations and pattern visualization with matplotlib and seaborn.
  3. PreprocessingHandling missing values and outliers, encoding categorical variables, and scaling.
  4. Feature engineering and PCACreating and selecting variables, and reducing to the components that explain more than 90% of the variance.
  5. Modeling and evaluationComparing encodings, scalers, polynomial terms and transformations (Yeo-Johnson) inside scikit-learn pipelines, measured with RMSE, R², recall, precision and accuracy.

Results

Linear regression: diamond prices (test R²)

  • Degree-2 polynomial0.963
  • One-hot + MinMax0.914
  • Ordinal + Robust0.903
  • Baseline0.846
Linear regression: diamond prices (test set)
ModelRMSE (USD)R²
Degree-2 polynomial ★7490.963
One-hot + MinMax1,1430.914
Ordinal + Robust1,2170.903
Baseline1,5320.846
Logistic regression: tumor classification (test set)
ModelRecallPrecisionAccuracy
Standard scaling + PCA ★0.9291.0097.4%
No correlated variables + Yeo-Johnson0.9291.0097.4%
No correlated variables0.9051.0096.5%

Conclusions

  • Moving from the baseline to the polynomial model cut the price error in half (from 1,532 to 749 USD RMSE).
  • In the classifier, PCA and the Yeo-Johnson transformation raised recall from 0.905 to 0.929 without losing precision. Recall was prioritized because in a medical diagnosis a false negative is the most serious error.
  • The instructor highlighted the reusable pipelines and the step-by-step justification of each model's performance.

Certifications earned in the course

Scope and limitations

These are academic labs using well-known public datasets, designed to practice each stage of the cycle, not production solutions. The models are linear and logistic; work with more complex models (ensembles, neural networks) continues in other courses of the master's program.

What it shows

  • Full data cycle: from extraction (CSV and SQL) to model evaluation, with reproducible code in notebooks.
  • Thoughtful preprocessing: choosing encodings, scaling and transformations based on the data, and measuring their effect.
  • Dimensionality reduction: using PCA to handle highly correlated variables.
  • Metrics that match the cost of errors: prioritizing recall when a false negative is the worst outcome.
  • ML best practices: scikit-learn pipelines that chain preprocessing and model to prevent data leakage.