GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — PythonDataAnalysisCookbook/c10_evaluating/ch10util.py at develop · wilsonify/PythonDataAnalysisCookbook

Expand file tree

/

ch10util.py

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
74 lines (53 loc) · 2.15 KB
/

ch10util.py

Copy path

File metadata and controls

74 lines (53 loc) · 2.15 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import numpy as np
import dautil as dl
from sklearn.utils import check_random_state
def classifiers():
return '''
bagging - BaggingClassifier {'n_estimators': 320, 'bootstrap_features': True, 'base_estimator__criterion': 'gini'}
default = DecisionTreeClassifier(random_state=53, min_samples_leaf=3, max_depth=4)
entropy = DecisionTreeClassifier(criterion='entropy', min_samples_leaf=3, max_depth=4, random_state=57)
random = DecisionTreeClassifier(splitter='random', min_samples_leaf=3, max_depth=4, random_state=5)
rfc - RandomForestClassifier {'min_samples_leaf': 3, 'n_estimators': 100, 'max_depth': 4, 'criterion': 'gini'}
stacking - DecisionTreeClassifier
votes - VotingClassifier {'voting': 'soft', 'weights': (2, 1, 1)}
'''
def regressors():
return '''
boosting - AdaBoostRegressor {'base_estimator__min_samples_leaf': 2,
'loss': 'exponential'}
etr = ExtraTreesRegressor{'min_samples_leaf': 4,
'bootstrap': True, 'min_samples_split': 1}
ransac - RANSACRegressor {'stop_probability': 0.99, 'max_trials': 50}
'''
def plot_bars(ax, vals, labels=None, rotate=False):
if labels is None:
dl.plotting.bar(ax, rain_labels(), vals)
ax.set_ylim(min(vals) - 0.03, max(vals))
else:
dl.plotting.bar(ax, labels, vals)
if rotate:
ax.set_xticklabels(labels, rotation='vertical')
def temp_labels():
return ['boosting', 'etr', 'ransac']
def rain_labels():
return ['bagging', 'default', 'entropy', 'random',
'rfc', 'stacking', 'votes']
def rain_preds():
files = rain_labels()
return [np.load(f + '.npy').T for f in files]
def temp_preds(full=False):
files = temp_labels()
return [np.load(f + '.npy').T for f in files]
def plot_bootstrap(reg, func, ax):
rs = check_random_state(34)
y_test = np.load('temp_y_test.npy')
n = len(y_test)
preds = np.load(reg + '.npy')
stats = []
for i in range(500):
indices = rs.choice(n, size=n)
stats.append(func(y_test[indices], preds[indices]))
dl.plotting.hist_norm_pdf(ax, np.array(stats))
ax.set_ylabel('Frequency')
ax.axvline(func(preds, y_test), color='k',
lw=3, label=reg + ' Observed')
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.