cleaning up
This commit is contained in:
@@ -742,12 +742,6 @@ display(grades)
|
||||
X = grades.loc[:, grades.columns != 'Grade'].values
|
||||
y = grades.loc[:, grades.columns == 'Grade'].values
|
||||
print(X)
|
||||
# Create the encoder.
|
||||
encoder = OneHotEncoder(handle_unknown="ignore")
|
||||
# Assume for simplicity all features are categorical.
|
||||
encoder.fit(X)
|
||||
# Apply the encoder.
|
||||
X = encoder.transform(X)
|
||||
# Then do a Classification tree
|
||||
tree_clf = DecisionTreeClassifier(max_depth=2)
|
||||
tree_clf.fit(X, y)
|
||||
@@ -763,9 +757,6 @@ cmd = 'dot -Tpng DataFiles/grade.dot -o DataFiles/grades.png'
|
||||
os.system(cmd)
|
||||
|
||||
|
||||
#data_pandas = pd.DataFrame(data,index=['Frodo','Bilbo','Aragorn','Sam'])
|
||||
#df.columns = ['First', 'Second', 'Third', 'Fourth', 'Fifth']
|
||||
|
||||
!ec
|
||||
|
||||
|
||||
@@ -1525,8 +1516,8 @@ for degree in range(1,maxdepth):
|
||||
print('Var:', variance[degree])
|
||||
print('{} >= {} + {} = {}'.format(error[degree], bias[degree], variance[degree], bias[degree]+variance[degree]))
|
||||
|
||||
mse_simpletree= np.mean( np.mean((y_test - simpleprediction)**2)
|
||||
print(mse_simpletree)
|
||||
mse_simpletree= np.mean( np.mean((y_test - simpleprediction)**2))
|
||||
print("Simple tree:",mse_simpletree)
|
||||
plt.xlim(1,maxdepth)
|
||||
plt.plot(polydegree, error, label='MSE')
|
||||
plt.plot(polydegree, bias, label='bias')
|
||||
|
||||
Reference in New Issue
Block a user