Skip to content
NumPy Study Part 8: Build k-means Clustering From Scratch With Only NumPy (Final Project) This is the final part of the NumPy Study series, and it is a project. We will build k-means clustering, one of the most widely used machine-learning algorithms, using only NumPy: no scikit-learn, no loops over data points.Every step uses something from an earlier part:StepNumPy ideaPartGenerate datadefault_rng, normal, concatenate1, 6Check shapesshape, reshape, newaxis2Select points in a cluste.. 2026. 10. 12.
NumPy Study Part 7: Math, Rounding, Missing Values and Linear Algebra (sqrt, round, isnan, dot, @, linalg) This part collects the numerical tools you reach for every day:Math functions: powers, roots, logs, exponentials, absolute valuesRounding: round, floor, ceil, trunc, and a surprise about .5Missing values: nan, isnan, the nan-functions, filling and droppingFloating-point comparison: why 0.1 + 0.2 == 0.3 is False, and iscloseLinear algebra: dot products, @, identity, inverse, determinant, solving .. 2026. 10. 12.
NumPy Study Part 6: Combine, Split, Sort and Count (concatenate, stack, split, sort, argsort, unique, clip) Real data rarely arrives in one tidy array. You load it in pieces, add new rows, split it into training and test sets, rank it, and count categories. This part covers the tools for all of that:Combining: concatenate, stack, vstack, hstack, column_stackAdding values: append, insert, delete (and why to use them sparingly)Splitting: split, array_splitSorting and ranking: sort, argsort, partition, t.. 2026. 10. 12.
NumPy Study Part 5: Broadcasting and Vectorization (Replace Your Loops and Understand Shape Errors) Two ideas separate people who use NumPy from people who are fluent in it:Vectorization: writing operations on whole arrays instead of looping over elements.Broadcasting: the rules NumPy uses to combine arrays of different shapes.They are the reason NumPy code is short and fast. They are also the source of the most common NumPy error message: operands could not be broadcast together with shapes ... 2026. 10. 12.
NumPy Study Part 4: Mastering axis (sum, mean, std, max, argmax, cumsum and keepdims) If there is one parameter that confuses almost everyone learning NumPy, it is axis. "Does axis=0 mean rows or columns?" is one of the most searched NumPy questions.By the end of this part you will have a mental model that answers that question every time, and you will know the full family of aggregation functions that use it: sum, mean, std, min, max, argmin, argmax, cumsum, percentile, and more.. 2026. 10. 12.
NumPy Study Part 3: Indexing, Slicing, Boolean Masks and np.where (Get Exactly the Data You Want) Creating arrays is step one. The thing you will do most often after that is selecting part of an array: one value, a row, a column, a block, or "every value greater than 50".NumPy gives you four selection tools, and this part covers all of them:Basic indexing: one element, a[2] or m[1, 3]Slicing: ranges, a[2:5] or m[:, 1]Fancy indexing: a list of positions, a[[0, 3, 4]]Boolean masks: a condition.. 2026. 10. 12.
NumPy Study Part 2: Inside an Array (shape, ndim, dtype, astype, reshape, flatten, newaxis) In Part 1 we created arrays. Now let's open one up. Most NumPy errors you will ever see, such as "operands could not be broadcast together" or "cannot reshape array", come down to two properties: shape and dtype. Once you can read those at a glance, debugging NumPy code becomes much easier. 1. The five attributes to check firstCODEimport numpy as npa = np.array([[1, 2, 3], [4, 5, 6].. 2026. 10. 12.
NumPy Study Part 1: Creating Arrays the Right Way (array, arange, linspace, zeros, ones, full, eye, random) Welcome to the NumPy Study series. Over eight parts we will go from "what is an array?" to building a small machine-learning algorithm with nothing but NumPy.Every part follows the same pattern:Why it matters: the problem the functions solve.Step-by-step examples: run them yourself in a Python shell or Jupyter.Common mistakes: the bugs everyone hits once.Practice: short exercises with answers.Al.. 2026. 10. 12.
728x90