New Contributor
Posts: 5
Registered: ‎04-17-2017
Accepted Solution

Workbench exits every time command is run in python 2

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
from sklearn.datasets import load_boston
%matplotlib inline

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

#So this a matrix of datapoints.
#We have 506 rows and 13 columns

#Lets see if we can learn more about these 506 rows
print boston.DESCR
boston_df = pd.DataFrame(
boston_df.columns = boston.feature_names

X = boston_df
y =

from sklearn.linear_model import LinearRegression
lm = LinearRegression(), 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_ +, 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')



Keep getting this exit error each time:

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



Cloudera Employee
Posts: 25
Registered: ‎07-09-2015

Re: Workbench exits every time command is run in python 2



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," 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.