Skip to content
Learn Netverks

Lesson

Step 12/36 33% through track

optimize-basics

Optimization basics

Last reviewed May 28, 2026 Content v20260528
Track mode
server_script
Means
Server runner
Reading
~1 min
Level
beginner

This lesson

This lesson teaches Optimization basics: SciPy scientific routines on NumPy arrays—statistics, optimization, linear algebra, and numerical methods.

Fitting parameters appears everywhere—from calibration to ML loss minimization.

You will apply Optimization basics in contexts like: Calibration, hyperparameter search, and engineering design optimization.

Read the narrative, run NumPy + SciPy snippets in the playground (install scipy and numpy with pip if needed), inspect outputs and convergence, and complete MCQs. Also verify the reported optimum by evaluating the objective nearby.

When you can explain the previous lesson's ideas in your own words.

scipy.optimize finds minima, maxima, and roots of scalar and vector functions—used in curve fitting, ML loss minimization, and engineering design after preparing NumPy inputs.

Core ideas

  • Objective — scalar function f(x) to minimize
  • Initial guess — starting point x₀ (quality matters)
  • Method — algorithm (BFGS, Nelder-Mead, L-BFGS-B, etc.)
  • Result objectx, fun, success, message

Scalar vs multivariate

  • minimize_scalar — one variable, bracket or bounded
  • minimize — vector x ∈ ℝⁿ
  • Always check result.success and residuals

Hello minimize

import numpy as np
from scipy import optimize

def f(x):
    return (x[0] - 2) ** 2 + (x[1] + 1) ** 2

res = optimize.minimize(f, x0=[0, 0], method='BFGS')
print('x:', res.x, 'f:', res.fun, 'success:', res.success)

Important interview questions and answers

  1. Q: Local vs global minimum?
    A: Most methods find local minima—try multiple x₀ or global search for hard landscapes.
  2. Q: Why BFGS?
    A: Popular quasi-Newton method for smooth unconstrained problems; no Hessian required.

Self-check

  1. What four items define an optimization problem?
  2. What attributes does minimize return?

Tip: Always print result.success and result.message after minimize.

Interview prep

minimize inputs?

Objective f(x), initial x0, method, optional bounds/jac.

success flag?

Always check result.success before using parameters.

Interview tip Lesson completion confidence

Can you explain this lesson in 30 seconds without reading notes?

Not saved yet.

Playground

Runs on the configured server runner (dev: npm run runner with LEARNING_RUNNER_ENABLED=true). Output appears below the editor.

Check yourself

Multiple choice — immediate feedback.

Discussion

Past discussion is visible to everyone. Only logged-in users can post comments and replies.

Starter discussion topics

  • Objective function?
  • Local minima?

Sign up or log in to post comments and sync lesson progress across devices.

No discussion yet. Be the first to ask a question.

Jump