6103 - Advanced ML
session: "6103-advanced-ml/2026-09-05 0924 Advance Machine Learning"
title: "Advance Machine Learning"
date: "2026-09-05 09:24"
duration: "1h 24m"
language: "en"
model: "deepseek-ai/DeepSeek-V3.2"
parts: 3
transcript_chars: 59617
generated: "2026-11-23T01:45:19+05:30"
This class introduced the essential Python libraries for machine learning: NumPy, pandas, matplotlib, scikit-learn, and seaborn. It focused on data visualization using matplotlib, covering basic plots, subplots, and various chart types. The session then transitioned to scikit-learn, demonstrating the complete workflow of loading a dataset (Iris), splitting data, training a k-nearest neighbors (KNN) classifier, evaluating accuracy, and making predictions. The class concluded with a brief mention of saving models. This practical session lays the foundational toolkit for implementing and visualizing machine learning models, preceding deeper dives into specific algorithms like linear regression and KNN.
Definition: Matplotlib is a low-level, open-source library for creating static, animated, and interactive visualizations in Python.
Why it matters: Visualizing data is crucial for understanding distributions, spotting patterns, and communicating results before and after model training.
Connection: It is used alongside pandas for data exploration and alongside scikit-learn for visualizing model performance (e.g., decision boundaries, error plots).
Definition: Scikit-learn is a comprehensive library providing consistent APIs for data preprocessing, model training, validation, and evaluation.
Why it matters: It standardizes the ML process, making it easier to implement, compare, and productionize algorithms.
Connection: It builds on NumPy and pandas for data handling and is the primary library used for implementing algorithms taught in the course, from linear regression to advanced models.
Definition: The practice of randomly partitioning a dataset into a subset for training the model and a separate subset for evaluating its performance.
Why it matters: It provides an unbiased estimate of model performance on unseen data, preventing overfitting.
Connection: It is a mandatory step after data loading and before model training in the scikit-learn workflow.
Definition: Saving a trained model to disk (using joblib or pickle) so it can be reloaded and used for predictions without retraining.
Why it matters: It enables deployment and reuse of models, saving computational resources.
Connection: It is the final step after model training and evaluation, allowing the model to be applied to new data in the future.
(No explicit formulas or equations were presented in this class.)
1. Line Plot: x = np.arange(0, 7) generates points [0,1,2,3,4,5,6]. y = [0, 250] plots a line from (0,0) to (6,250).
2. Markers: Adding marker='o' to plt.plot(x, y) displays points on the line.
3. Labels & Title: plt.xlabel("average pulse"), plt.ylabel("calorie voltage"), plt.title("sport watch data").
4. Subplots: plt.subplot(1, 2, 1) and plt.subplot(1, 2, 2) create two plots side-by-side in a 1-row, 2-column figure.
5. Scatter Plot: plt.scatter(x, y) creates a scatter plot instead of a line plot.
6. Bar Chart: plt.bar(x, y, color='red', width=0.1) creates a red bar chart with specified bar width.
7. Histogram: x = np.random.uniform(170, 10, 100) generates 100 random values around 170. plt.hist(x) plots their frequency distribution.
8. Pie Chart: y = np.array([35, 25, 25, 15]). plt.pie(y, labels=['apple', 'banana', 'cherry', 'dates'], startangle=90, explode=(0.2, 0, 0, 0)) creates a labeled pie chart starting at 90 degrees, with the first slice ('apple') exploded out by 0.2.
1. Load Data: Iris dataset features: ['sepal length', 'sepal width', 'petal length', 'petal width']. Target names: ['setosa', 'versicolor', 'virginica'].
2. Split Data: train_test_split(X, y, test_size=0.3, random_state=42).
X_train shape (105, 4), X_test shape (45, 4); y_train shape (105,), y_test shape (45,).3. Train KNN: knn = KNeighborsClassifier(n_neighbors=3). knn.fit(X_train, y_train).
4. Evaluate: y_pred = knn.predict(X_test). accuracy_score(y_test, y_pred) returned 98.33%.
5. Predict New Samples:
[[5.1, 3.5, 1.4, 0.2]] → Predicted species: 'versicolor'.[[100, 20, 30, 40]] → Predicted species: 'virginica'.marker parameter adds points to a line plot; without it, only a line is drawn.plt.subplot() function allows multiple plots to be arranged within a single figure.startangle parameter rotates the chart, and the explode parameter offsets a slice for emphasis.load_* functions provide easy access to standard datasets like Iris for practice.train_test_split), 3) Train Model (model.fit), 4) Evaluate Model (model.predict, accuracy_score).random_state parameter in train_test_split ensures the data split is reproducible.joblib.dump and later reloaded with joblib.load for predictions on new data.fit method is used for training, and the predict method is used for generating predictions on new data.1. Describe the purpose of the train_test_split function in scikit-learn and explain the role of the random_state parameter.
train_test_split partitions data into training and testing sets to evaluate model performance on unseen data. The random_state parameter seeds the random number generator, ensuring the same split is produced every time the code is run, which is crucial for reproducibility.2. Given a dataset with 150 samples, you perform train_test_split with test_size=0.3. What will be the dimensions of your X_train and X_test arrays?
test_size=0.3 means 30% of 150 samples (45 samples) are used for testing. Therefore, X_test will have 45 rows. The remaining 70% (105 samples) will be for training, so X_train will have 105 rows. The number of columns depends on the features.3. You have trained a KNN classifier and achieved 95% accuracy on the test set. You then use the model to predict a brand new, single sample. Does this prediction affect the model's previously calculated accuracy score? Why or why not?
4. When creating a histogram, why is it incorrect to pass a single value (e.g., plt.hist(170))? What does a histogram actually represent?
sklearn) used for efficiently saving and loading Python objects, especially trained ML models.n_neighbors value will be covered in an upcoming class.sklearn.metrics.
One line per segment, [hh:mm:ss] timestamp first.
loading…