# Support Questions

Announcements
Celebrating as our community reaches 100,000 members! Thank you!

## Workbench exits every time lm.fit command is run in python 2

Explorer

Trying to run the below code for boston housing linear regression analysis:

import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
import scipy.stats as stats
import sklearn
%matplotlib inline

#This creates a dictionary that has data inside of it. ls look at the keys of this dictionary
print boston.keys()

#print boston.data
#So this a matrix of datapoints.
print boston.data.shape
#We have 506 rows and 13 columns

print boston.DESCR
boston_df = pd.DataFrame(boston.data)
boston_df.columns = boston.feature_names

boston_df.describe()
X = boston_df
y = boston.target

from sklearn.linear_model import LinearRegression
lm = LinearRegression()

lm.fit(X, y)
print 'Estimated intercept coefficent:', lm.intercept_
print 'Number of coefficients:', len(lm.coef_)

pd.DataFrame(zip(boston_df.columns, lm.coef_), columns=['feature', 'coefficient'])

print "Predicted House price", lm.predict(X)[41] * 1000
print "Equation house price", (lm.intercept_ + np.dot(lm.coef_, X.iloc[[41]].values[0])) * 1000
print "Target price", y[41] * 1000

print "Residual price", (lm.predict(X)[41] - y[41]) * 1000

print "R^2 =", lm.score(X, y)

plt.scatter(y, lm.predict(X))
plt.xlabel('Prices: $Y_i$')
plt.ylabel('PredictedPrices: $\hat{Y}_i$')
plt.title('Actual vs Predicted')
plt.plot()

Keep getting this exit error each time:

lm = LinearRegression()
lm.fit(X, y)
Engine exited with status 2.

1 ACCEPTED SOLUTION
Super Collaborator

Hello,

I can reproduce the "Engine exited with status 2." if I'm using the v1 engine but it works with the v2 engine.

What version are you using?

- If you are using 1.0.x then I recommend upgrading to 1.1.1.

- If you are already using 1.1.1 then you should use the v2 engine. You can go to your Settings menu on the Project page and select the "Base Image v2, docker.repository.cloudera.com/cdsw/engine:2" on the Engines tab. You can also change the default engine in the Admin menu but it will be applied to new projects, for already existing ones you need to select it manually.

Regards,

Peter

Super Collaborator

Hello,

I can reproduce the "Engine exited with status 2." if I'm using the v1 engine but it works with the v2 engine.

What version are you using?

- If you are using 1.0.x then I recommend upgrading to 1.1.1.

- If you are already using 1.1.1 then you should use the v2 engine. You can go to your Settings menu on the Project page and select the "Base Image v2, docker.repository.cloudera.com/cdsw/engine:2" on the Engines tab. You can also change the default engine in the Admin menu but it will be applied to new projects, for already existing ones you need to select it manually.

Regards,

Peter

Announcements
What's New @ Cloudera
What's New @ Cloudera
Community Announcements
What's New @ Cloudera
Product Announcements