fix slicing of coefficient arrays in some notebooks [skip ci]#1005
fix slicing of coefficient arrays in some notebooks [skip ci]#1005eordentlich merged 2 commits intoNVIDIA:mainfrom
Conversation
…ported when these vectors happen to be sparse, mainly cpu case Signed-off-by: Erik Ordentlich <eordentlich@gmail.com>
|
build |
Greptile OverviewGreptile SummaryThis PR fixes a critical runtime error that occurs when coefficient vectors happen to be sparse. PySpark's Vector objects support single-element indexing ( Changes MadeLinear Regression Notebook (3 fixes):
Logistic Regression Notebook (3 fixes):
Technical ContextThe PR description correctly identifies this affects "mainly cpu case" because Spark ML (CPU) models are more likely to return sparse coefficient vectors, especially with L1 regularization. The fix ensures notebooks work regardless of whether coefficients are sparse or dense. Verification
Confidence Score: 5/5
Important Files ChangedFile Analysis
Sequence DiagramsequenceDiagram
participant User
participant Notebook
participant Model
participant Vector
participant Array
User->>Notebook: Execute coefficient display cell
Notebook->>Model: Access .coefficients property
Model-->>Notebook: Return Vector object (sparse or dense)
alt Before Fix (Slicing fails on sparse)
Notebook->>Vector: Apply slice [0:10]
Vector-->>Notebook: ❌ Error (sparse vectors don't support slicing)
end
alt After Fix (Works for both)
Notebook->>Vector: Call .toArray()
Vector-->>Notebook: Return numpy array
Notebook->>Array: Apply slice [0:10]
Array-->>User: ✅ Display first 10 coefficients
end
|
Additional Comments (1)
|
Signed-off-by: Erik Ordentlich <eordentlich@gmail.com>
|
build |
slicing not supported when these vectors happen to be sparse, mainly cpu case, but changed gpu case for consistency.