Calmcode - cvxpy one: enter cvxpy

Enter cvxpy

1 2 3 4 5 6 7

You can download the dataset directly.

But you can also pull it in locally by running this on the terminal;

wget https://calmcode.io/datasets/stigler.csv

Install

You need to install some tools before starting your notebook.

pip install cvxpy pandas

The notebook in this video contains the following code;

import cvxpy as cp
import pandas as pd

df = pd.read_csv("/path/to/stigler.csv")
price = df['price_cents'].values

x = cp.Variable(price.shape[0])
objective = cp.Minimize(cp.sum(price*x))
prob = cp.Problem(objective)
prob.solve()