Statsmodel OLS.fit generates "Error displaying widget: undefined"

JU1
New Contributor III

Hi,

I am running some code which fits a linear model via Statsmodel. Everytime I run the .fit function it generates the error: "Error displaying widget: undefined".

I can reproduce the error via the simple code below.

I am not sure what is causing this issue and I cannot find any similar issues online. Is anybody aware of the issue causing this error?

Node type: Standard_DS3_v2

Databricks runtime version: 15.1 ML

Statsmodel version: 0.14.0

 

import statsmodels.api as sm
import pandas as pd

# Create sample data
data = {
    "X": [1, 2, 3, 4, 5],
    "Y": [2, 4, 5, 4, 5]
}

df = pd.DataFrame(data)

# Define independent and dependent variables
X = sm.add_constant(df["X"])  # Add constant for intercept
y = df["Y"]

# Fit OLS model
model = sm.OLS(y, X).fit()
 
 
JU1_0-1738313760137.png