
The lecture shows how collaborative filtering uses math to compute user similarities with Euclidean, Manhattan, cosine, and Pearson metrics, then predicts ratings by weighting similar users' ratings.
Learn how mean squared error serves as a regression evaluation metric by computing the average of squared differences between actual and predicted values, with a step-by-step example.
Learn how principal component analysis reduces dimensionality by standardizing data, computing a covariance matrix, deriving eigenvalues and eigenvectors, and projecting onto the top components.
Explore classification evaluation metrics, including the confusion matrix for multi-class problems, and learn precision, recall, F1 score, and accuracy calculated from true positives, false positives, false negatives, and diagonal sums.
Set up your conda environment with Anaconda Navigator, install and launch Jupyter, create a data folder, place the dataset, and start a Python 3 ipy kernel for ML experiments.
Import required libraries for data handling, visualization, and machine learning, including pandas, numpy, matplotlib, seaborn, scipy, networkx, and scikit-learn tools like grid search cv and PCA.
Import Trax.csv with pandas read_csv, then describe its numerical features, such as danceability, keys, and loudness, across 7994 instances for a data-driven song recommendation pipeline.
Extract unique genres from the dataset and assess missing data by counting null values per column. Confirm no nulls, then perform feature extraction and visualize the features.
Explore correlation testing with Pearson correlation via a Seaborn heatmap of numerical features, with annotated values and discussion of positive and negative relationships.
Encode categorical genre data and build a user-genre interaction matrix, then apply collaborative filtering with simulated ten users and random genre selections.
Create a cosine similarity based user similarity matrix, build a network with nodes and weighted edges, apply a 0.5 threshold, and visualize a force-directed layout for song recommendations.
Implement a collaborative filtering engine to generate song recommendations by comparing user profiles with cosine similarity, selecting similar users, and returning top-n genre-based songs.
Explore k-means clustering and PCA to group songs into five clusters—high energy dance, mellow acoustic, pop hits, instrumentals, heavy speech—and visualize centroids for a song recommendation pipeline.
You can find the links to the required tools and libraries we need for this experimentation below:
1. Anaconda Navigator: https://www.anaconda.com/download
2. Hyper Terminal: https://hyper.is/
3. PyCharm Community Edition: https://www.jetbrains.com/pycharm/download/?section=windows
4. Docker: https://www.docker.com/products/docker-desktop/
(Note: In the next module, we don't need the swagger_api.py file.)
In train_and_deploy.py, it contains the same code as written in the Airflow implementation, but without the Airflow configurations. That's the only difference. You can download and upload the train_and_deploy.py code to your codebase, or if you want to start from scratch, feel free to do so :)
Let me know if you need further adjustments!
Master the docker compose lifecycle by defining services, networks, and volumes for MLflow, Airflow, and Postgres; build, bring up, and bring down containers to orchestrate ML pipelines.
Learn the dockerfile lifecycle, creating a python or airflow image, then build and run containers, using run, copy, expose, and cmd in a /app directory.
Define a docker compose setup to deploy mlflow and airflow microservices. Configure mlflow server on port 5000, postgres storage, volumes, and the airflow mlflow network.
Build a docker image for airflow using python 3.9 and Airflow 2.6.3, install system and library dependencies, copy requirements, install packages, and configure MLflow tracking URI.
Build and compose the microservices for the song recommendation pipeline by containerizing mlflow, airflow, and postgres, mounting dags, logs, datasets, and models, and launching with docker compose up -d.
Orchestrate airflow triggers and mlflow tracking to train, log, and deploy a music recommendation model, capturing metrics, artifacts, and dockerized dag workflows.
Create a load model function that reads a pkl file from a path, uses try and catch, logs errors with Streamlit, and returns the pickle model or none on failure.
Load the collaborative filtering model and tracks data, then build a fallback recommender in Streamlit catch resource. Apply tf-idf with English stop words to song data using fittransform, returning scores.
Build a music recommender UI in streamlit with a multi-select genre dropdown defaulting to pop, a Get recommendations button, validating at least one genre and using cosine similarity for recommendations.
Apply filtering techniques to generate top songs by genre ranked by track popularity, using a lambda to lowercase genres, then join genres and display the top five recommended tracks.
Run the streamlit app locally with streamlit run App.py to test genre-based recommendations, listen to tracks, handle warnings when no genre is selected, then create a GitHub repo and deploy.
Math Behind Machine Learning Algorithms:
K-Nearest Neighbors (KNN): A method for finding similar songs based on user preferences.
Random Forest (RF): An algorithm that combines many decision trees for better predictions.
Principal Component Analysis (PCA): A technique for reducing the number of features while retaining important information.
K-Means Clustering: A way to group similar songs together based on features.
Collaborative Filtering: Making recommendations based on user interactions and preferences.
Data Processing Techniques:
Feature Engineering (Feature Importance using Random Forest): Feature importance analysis and creating new features from existing data to improve model accuracy.
Data Pre-processing (Missing Data Imputation): Cleaning and preparing data for analysis.
Evaluation and Tuning:
Hyperparameter Tuning (Collaborative Filtering, KNN, Naive Bayes Classifier): Adjusting the settings of algorithms to improve performance.
Evaluation Metrics (Precision, Recall, ROC, Accuracy, MSE): Methods to measure how well the model performs.
Data Science Fundamentals:
TF-IDF (Term Frequency and Inverse Document Frequency): A technique for analyzing the importance of words in song lyrics.
Correlation Analysis: Understanding how different features relate to each other.
T-Test: A statistical method for comparing groups of data.
Automation Tools:
Building Microservices using Docker: Use containers to run applications consistently across different environments.
Airflow: Automate workflows and schedule tasks for running ML models.
MLFlow: Manage and track machine learning experiments and models effectively.
By the end of the course, you will know how to build and automate the training, evaluation, and deployment of an ML model for a song recommendation system using these tools, libraries and techniques.