index
execution_count
cell_type
toolbar
started_at
completed_at
source
loc
metadata
outputs
1
unexecuted
In
[
]
markdown
# 3d plots from html tables
lets use html and html to try to make a 3d plot. most plotting is an ends where the table is the means.
if we can generate plots from tabular data then we could encourage more complete tables in scientific literature.
metadata
4
lets use html and html to try to make a 3d plot. most plotting is an ends where the table is the means.
if we can generate plots from tabular data then we could encourage more complete tables in scientific literature.
2
executed
In
[
1
]
code
%%
shell . environment . globals . update ( vars ( __builtins__ ))
metadata
3
0 outputs.
Out
[
1
]
3
executed
In
[
2
]
code
%%
## making sample data
create some randomized datasets with distinct clusters
import sklearn.datasets , sklearn.discriminant_analysis , sklearn.model_selection
features = 6
df = pandas . DataFrame ( * sklearn . datasets . make_blobs ( 200 , features , centers = [
( i ** 2 ,) * features for i in range ( features )
]))
df = pandas . concat ( dict ( zip ( "test train" . split (), sklearn . model_selection . train_test_split ( df ))))
df = df . rename_axis ( index = "selection blob" . split ())
apply statistical analysis to reduce the dimensionality of the data .
a sample of the full and reduced dataset are shown next , with the source as a caption .
< figure >
{{ df . sample ( 2 ) . style . to_html ()}}
< figcaption >
model = sklearn . discriminant_analysis . LinearDiscriminantAnalysis ( n_components = 3 )
model . fit ( df . loc [ "test" ], df . loc [ "test" ] . index )
df = df . combine_first (
pandas . DataFrame ( model . transform ( df . values ), columns = list ( "xyz" ), index = df . index )
)
df = pandas . concat ([ df , pandas . DataFrame ([[ - 1 ] * features + [ 0 , 0 , 0 ]] , pandas . MultiIndex . from_tuples ([( "test" , - 1 )]), df . columns )])
</ figcaption ></ figure >
metadata
29
1 outputs.
Out
[
2
]
create some randomized datasets with distinct clusters
import sklearn.datasets, sklearn.discriminant_analysis, sklearn.model_selection
features = 6
df = pandas.DataFrame(*sklearn.datasets.make_blobs(200, features, centers=[
(i**2,)*features for i in range(features)
]))
df = pandas.concat(dict(zip("test train".split(), sklearn.model_selection.train_test_split(df))))
df = df.rename_axis(index="selection blob".split())
apply statistical analysis to reduce the dimensionality of the data.
a sample of the full and reduced dataset are shown next, with the source as a caption.
0
1
2
3
4
5
x
y
z
test
3
9.830273
9.151163
11.189289
9.057340
8.674574
8.675005
1.104807
-0.331329
-0.317266
1
0.111571
1.710573
0.153907
2.878302
1.887411
0.045487
-22.539861
-1.035561
-1.366237
model = sklearn.discriminant_analysis.LinearDiscriminantAnalysis(n_components=3)
model.fit(df.loc["test"], df.loc["test"].index)
df = df.combine_first(
pandas.DataFrame(model.transform(df.values), columns=list("xyz"), index=df.index)
)
df = pandas.concat([df, pandas.DataFrame([[-1]*features+ [0,0,0]] , pandas.MultiIndex.from_tuples([("test", -1)]), df.columns)])
4
executed
In
[
3
]
code
%%
## generate a 3d plot in an image for comparsion
we 'll compare our interactive css outcomes with rendered html image.
import matplotlib.pyplot
fig = matplotlib . pyplot . figure ()
ax = fig . add_subplot ( projection = "3d" )
df [ list ( "xyz" )] . apply ( lambda x : ax . scatter ( * x . values , c = x . name [ 1 ]), axis = 1 );
metadata
9
2 outputs.
Out
[
3
]
we'll compare our interactive css outcomes with rendered html image.
import matplotlib.pyplot
fig = matplotlib.pyplot.figure()
ax = fig.add_subplot(projection="3d")
df[list("xyz")].apply(lambda x: ax.scatter(*x.values, c=x.name[1]), axis=1);
5
executed
In
[
4
]
code
%%
## creating our table
table = \
{ % set format = " %.2f " % }
< table role = table id = pca >
< tbody role = rowgroup style = "--x-min: {{df.x.min()}}; --x-max: {{df.x.max()}}; --y-min: {{df.y.min()}}; --y-max: {{df.y.max()}};
-- z - min : {{ df . z . min ()}}; -- z - max : {{ df . z . max ()}}; ">
{ %- for i , ( _ , row ) in enumerate ( df . iterrows ()) -% }
< tr role = row style = "--x: {{row.loc['x']}}; --y: {{row.loc['y']}}; --z: {{row.loc['z']}};" >
< th role = rowheader > {{ i }} </ th >
{ %- for j in range ( features ) -% }
< td role = cell > {{ format % row . loc [ j ]}} </ td >
{ %- endfor % }{ % for j in "xyz" -% }
< td role = cell hidden > {{ row . loc [ j ]}} </ td >
{ %- endfor % } </ tr >
{ %- endfor % } </ tbody >
</ table >
form = \
< form name = controls >
< script >
function rotate ( axis , el ){
document . getElementById ( "pca" ) . style . setProperty ( ` -- rotate - $ { axis } ` , `$ { el . value } deg ` );
}
</ script >
< label > x
< input type = range min = 0 max = 360 value = 350 step = 5 oninput = "rotate('x', this)" name = "x" />
</ label >
< label > y
< input type = range min = 0 max = 360 value = 5 step = 5 oninput = "rotate('y', this)" name = "y" />
</ label >
< label > z
< input type = range min = 0 max = 360 value = 15 step = 5 oninput = "rotate('z', this)" name = "z" />
</ label >
< label > show table < input type = checkbox name = show checked onchange = "document.getElementById('pca-style').setAttribute('media', this.checked ? 'screen': 'none')" /></ label >
</ form >
< details >
< summary > html table source </ summary >
``` html
{{ table }}
```
</ details >
< details >
< summary > form source </ summary >
``` html
{{ form }}
```
</ details >
metadata
58
1 outputs.
Out
[
4
]
table =\
0
4.64
2.66
4.03
3.56
2.23
3.19
-15.767281376409397
-0.745360508047773
1.1279681190529915
1
-0.40
0.90
-0.06
0.89
-0.69
-0.38
-25.349022723607735
-0.02031209898608877
-0.6653164523934019
2
-0.45
0.18
-2.10
-0.38
0.54
-1.37
-27.069091141497033
0.30992648034096854
0.05707886721758662
3
16.21
17.33
15.45
17.27
15.97
15.45
19.527117740686933
-0.38040770275303176
-0.5681734311490066
4
7.53
10.52
9.06
9.56
8.66
8.73
-0.5599017558516147
0.5403181112067015
-1.744057168268122
5
0.28
-0.05
-0.24
0.08
0.02
0.21
-25.140199457802986
0.013553680838879466
0.5201735128644481
6
15.94
15.45
16.67
14.37
16.28
15.61
18.605471961865668
0.4311575976753309
0.04714403915195655
7
0.12
1.74
0.10
0.60
0.15
0.76
-23.79188354393285
0.9525895933267234
-0.2796908187752626
8
15.75
17.21
14.96
15.63
14.07
17.78
18.55750547346919
1.459732335493263
0.891115449530507
9
8.71
10.97
7.89
9.41
9.32
9.49
0.21966912131111446
1.125086655831838
-0.3497084747121219
10
24.13
25.24
25.34
24.84
23.15
26.47
43.47427939658191
0.30881987933265725
-0.04168811837734105
11
8.44
8.27
8.16
9.03
9.61
9.10
-1.0636749234360081
-0.566321835908732
0.16238542188520735
12
14.33
15.71
16.98
13.71
15.52
16.83
18.005906539491562
1.4858782329006845
-0.6280005192908321
13
23.60
25.49
23.69
25.85
24.52
24.45
42.46621903064036
-0.6462151710030114
-1.087733576200874
14
15.47
17.22
15.56
17.01
13.34
15.80
17.940503062812976
-0.012962717946214699
-0.49183007353409747
15
0.87
-1.34
1.31
2.12
2.56
0.11
-22.654309863813996
-2.7236654324753324
-0.1305856104229082
16
7.96
7.96
8.95
8.84
7.74
10.23
-1.4768931439440607
-0.3093379379186751
0.3744600296499882
17
5.34
3.44
5.43
4.03
3.90
5.23
-12.389920849381083
-0.3303291461631136
1.2120802368863401
18
25.15
26.99
24.34
24.62
26.16
24.42
44.69163480315481
1.0781072545145565
-0.714022049209723
19
24.70
24.79
25.84
25.69
24.37
25.85
44.45900199483313
-0.9196123037551759
-0.29512895816598006
20
24.64
25.22
26.11
25.70
26.45
26.19
45.94779995958922
-0.6801349080956375
-0.8211642430492685
21
15.61
17.28
16.06
16.42
16.74
16.64
20.186333603318193
0.4317980129851091
-0.7278094652103595
22
4.05
5.22
4.00
3.71
4.62
3.99
-13.431598603182124
0.9956834698799353
-0.3184805900926823
23
25.23
25.37
26.40
25.19
25.12
25.74
45.471685959962485
-0.27489046975168724
-0.3765127643132955
24
0.51
-0.01
1.14
0.69
-0.01
0.72
-23.814954345539626
-0.42359743254055643
0.18960160629338804
25
16.56
15.88
16.09
14.97
15.59
14.16
17.981480481818718
0.007052560670021553
0.027952174492147895
26
3.13
6.06
2.68
4.42
4.78
4.42
-13.813926119385089
1.2911247975044755
-0.7927175032970242
27
14.47
17.15
16.48
15.24
18.20
14.89
19.334162620633396
0.7767442427523777
-2.346646235068402
28
9.23
7.90
9.89
9.14
9.06
7.84
-0.6285658934484109
-1.3372981810730038
-0.22043239242943047
29
1.04
1.52
0.92
1.38
-0.45
1.32
-22.74985396715908
0.2636666575536246
0.30015823235024264
30
-0.01
0.71
1.84
0.11
-1.28
2.03
-23.614820699221017
0.8483767013283254
0.11681497241960216
31
5.51
4.33
2.77
3.52
3.71
4.89
-13.833868200135935
0.7958093233543713
2.100234766430302
32
2.66
3.72
3.27
2.51
3.49
4.31
-15.996883808084755
1.1258932920567593
0.031402018118813046
33
-0.44
0.64
-1.21
-0.63
-1.24
-1.23
-27.262114496736295
0.8705549800965772
-0.035280664660270494
34
25.33
25.12
24.48
27.23
24.43
25.07
44.32120476726261
-1.9454577482539455
-0.04638431065311522
35
17.75
16.14
16.25
16.42
15.75
16.28
20.291885999737108
-0.5076574585321539
1.2135548675784331
36
1.22
0.13
1.96
2.61
0.64
1.91
-21.462908287602573
-1.6371887608168638
0.2584064249275078
37
24.33
23.87
27.23
26.23
24.95
23.57
44.08976557074776
-2.5906282070614037
-1.877610612059134
38
16.05
15.68
16.65
16.29
16.08
17.54
20.11563372603606
-0.4093833083567064
0.39723540906916943
39
16.80
16.38
14.03
15.69
17.15
16.62
19.257291831638927
0.42381186270693916
1.3549586346332798
40
9.83
9.15
11.19
9.06
8.67
8.68
1.1048066594315566
-0.33132864455507527
-0.3172655836911916
41
17.17
15.00
15.90
16.09
16.78
17.17
20.114052942652073
-0.8391485762364864
1.5469739454965616
42
25.40
26.41
24.46
24.82
23.61
25.79
44.06111575884158
0.9513700659325436
0.520928995566451
43
9.38
7.95
9.86
9.12
8.37
10.35
0.2339155672972781
-0.6797285140434944
0.9557691355683514
44
8.75
9.01
8.24
9.41
8.90
9.90
-0.4083371176738418
-0.13892557701094754
0.4412984050013191
45
8.85
6.07
9.58
9.93
8.18
10.17
-0.9237537339475639
-2.570902784116385
1.1043179564354588
46
26.11
25.75
24.47
25.43
24.61
24.04
44.0688220349553
-0.441563434014923
0.31077887654678404
47
1.29
1.34
0.05
1.20
2.71
0.82
-21.90064297526901
0.041306415036422406
0.2062485646663238
48
16.29
16.59
14.49
15.50
15.61
17.31
18.832511688425654
0.9549287793191467
1.287603295467254
49
0.91
-0.13
0.88
1.74
1.38
2.78
-21.865420222771576
-0.9064366449186279
0.9487034381684749
50
4.17
5.43
5.04
5.19
2.73
3.78
-13.254221138157629
-0.006097532287368011
-0.8015963325776587
51
8.07
7.23
10.81
11.19
7.92
7.74
-0.9814374689013657
-3.302460946169038
-1.5203574129257882
52
0.44
-1.06
0.68
1.54
0.60
-0.03
-24.32681370166575
-1.9477192236004581
0.10707547563725119
53
16.49
16.69
15.62
15.77
16.34
16.91
19.877435589924392
0.5859684619439557
0.616791852087156
54
-2.27
-0.38
0.70
-1.48
0.73
0.13
-26.262952871761144
0.9497213473135573
-1.4414013796315381
55
8.88
9.93
9.06
8.25
8.82
9.37
-0.1349896316493733
1.1731413822649308
-0.02808926223729151
56
9.33
9.03
8.89
8.47
9.76
10.15
0.5114912718518217
0.5081609214055707
0.7639078920234722
57
9.16
8.43
6.90
9.56
8.58
10.57
-1.0092269205272062
-0.40011429569125584
1.7435342024022522
58
9.63
9.91
9.81
11.21
8.73
8.13
0.994551668661865
-1.4255323613401765
-0.8744355027127992
59
15.18
15.80
16.27
16.52
16.97
16.95
19.741758149601576
-0.6040541793885653
-0.5658132964222259
60
7.62
7.91
11.73
9.24
9.61
9.03
0.3988220672474899
-1.218935592622868
-1.8207092035863637
61
2.17
1.35
-0.18
1.53
0.67
0.01
-22.828230686520712
-0.30051054887589673
0.9175197225340554
62
16.84
17.37
16.91
13.59
17.12
16.28
20.500245199828793
2.379189175096245
0.24709131158398998
63
-0.76
2.35
0.33
0.73
0.03
-0.07
-24.27032795228488
1.1225354342013592
-1.5511355531878896
64
24.91
23.63
24.15
22.53
24.40
26.12
42.2891754934785
0.8339380424035274
1.733589579923276
65
23.85
24.56
24.75
25.10
24.82
24.84
42.88906249088707
-0.753896130407065
-0.7371515319394766
66
8.12
8.73
9.86
6.23
8.04
10.16
-1.2528666601241352
2.0616609247913327
0.38404922280764037
67
24.40
26.12
23.99
22.18
25.70
24.59
42.82514082898894
2.435806663593231
-0.14984594934873785
68
3.65
4.47
3.69
2.61
4.07
3.62
-14.907522671425378
1.295872889873558
-0.0387009964583817
69
10.58
9.95
9.18
8.91
9.38
8.14
0.7638497487061289
0.28964462009214464
0.47542598028325983
70
2.40
-0.06
1.04
1.24
-0.09
0.26
-22.971734725760573
-1.0639839955847243
1.3743784807336623
71
4.63
2.83
3.83
3.99
4.13
4.08
-14.336652975006313
-0.8306018326216817
1.0538896454185742
72
16.31
16.59
16.29
16.85
16.04
15.22
19.545571453675567
-0.703377412946653
-0.5722747766593225
73
5.01
4.42
4.38
5.24
4.27
4.43
-12.54480003276229
-0.6647680900827863
0.4017017287793985
74
0.11
1.71
0.15
2.88
1.89
0.05
-22.53986063980194
-1.0355609429878398
-1.3662365292793561
75
3.23
2.47
3.94
2.87
5.69
5.06
-14.307807359056648
-0.039534547650616814
0.4508053742182622
76
5.21
5.50
4.26
3.65
3.75
4.08
-12.960564410219902
1.220189315968375
0.5423209281843895
77
-0.21
-1.87
-0.35
-0.07
0.54
-0.62
-26.391776513138442
-1.323292651594325
0.45892982749252015
78
9.18
8.96
9.95
9.61
10.17
7.38
0.30383769364432306
-1.1190600883370634
-1.108869072744246
79
23.48
24.82
26.37
24.89
24.70
26.22
44.209537114232305
-0.2058299998745547
-1.1578074040435526
80
1.18
-1.39
-0.02
-0.30
1.41
1.22
-24.080794723907072
-0.545508941130633
1.7963407589792098
81
15.63
16.10
15.95
16.80
15.42
16.64
19.100586069693307
-0.587335840691802
-0.12975152118439423
82
-0.90
-0.30
-0.83
-2.16
0.08
-0.00
-26.9546970636675
1.5737097556360347
0.36948393881617764
83
9.76
9.95
8.63
10.35
9.62
8.27
0.6552152321825626
-0.6831825881954224
-0.23303328937354695
84
25.74
25.30
24.26
22.64
25.92
26.94
44.64503341876943
1.955318175373875
1.768810305346279
85
-1.53
-0.21
0.26
-1.46
-0.04
-0.82
-26.846787375491548
0.8767115026829655
-1.0058292043230244
86
14.95
17.04
17.22
15.75
16.67
17.09
20.347224458702215
0.8175352111604435
-1.264600188872158
87
25.00
24.29
26.78
24.79
25.44
27.19
45.78334815592155
-0.4316625483364383
0.26036806937427737
88
2.03
1.11
0.26
1.65
1.95
0.27
-21.96846128611158
-0.5873038103042427
0.5824035014876477
89
-0.61
0.25
-0.14
-0.07
0.36
-0.64
-25.68046306373955
0.16094545253860387
-0.623630890600611
90
3.68
4.72
4.13
2.85
4.84
4.22
-13.819079635806597
1.3440275925125273
-0.23178403051162083
91
-1.31
1.46
0.40
0.76
0.21
-1.59
-25.477726158669878
0.15395596254026078
-2.302987221305192
92
-0.39
4.18
2.55
0.47
0.41
0.22
-21.819548154367975
2.428450570197778
-2.6874493019749535
93
24.86
26.24
25.37
23.57
25.37
24.52
44.13304301435074
1.3487193243466629
-0.6813069316562571
94
-0.65
0.36
0.20
1.17
-0.21
-0.68
-25.38406029756845
-0.6961628255808128
-1.0281622353260342
95
-0.48
2.06
3.72
2.38
1.30
2.39
-20.090714118779015
-0.11353436633720829
-2.242247237831725
96
24.53
25.99
22.95
25.38
24.43
24.60
42.62326227340311
0.09795081406436253
-0.09677271710646115
97
4.22
4.27
5.29
4.59
3.96
5.94
-12.189555103343706
0.050766712745649305
0.27824571309059704
98
0.07
0.41
-0.26
0.44
4.84
1.35
-22.055004368763814
0.06313841892470494
-0.25046798571327755
99
0.30
1.09
-0.81
1.09
1.22
-1.04
-24.61294526652513
-0.2696083667871829
-0.5294484920312745
100
5.11
4.89
3.67
4.33
2.30
4.70
-13.824393560167701
0.566100155682365
1.2334361866042003
101
0.17
0.34
1.61
-0.40
-1.74
-1.17
-25.62497853078969
0.2807476520639489
-0.5427255501830736
102
2.19
1.17
-1.00
1.09
2.11
-0.46
-22.993793914167853
-0.2101798596292629
0.9934681403540311
103
-0.28
0.78
0.92
-0.86
-1.12
-0.39
-25.549892872471908
1.1456634383385773
-0.46349361390995497
104
3.23
0.98
-0.92
2.24
1.56
2.54
-21.048185470082917
-0.555326295651031
2.768832194657384
105
15.81
17.77
16.60
15.46
16.18
16.04
19.958298187508856
1.3299487077957632
-0.8755433187780712
106
24.40
23.84
24.42
23.64
25.38
25.11
42.62785290196732
-0.12330922595127504
0.38808174709667265
107
25.17
23.06
25.93
23.83
25.05
26.29
43.98259824090018
-0.6827658467279779
1.0930641150455807
108
-1.26
-0.25
-1.30
1.26
0.45
-0.02
-26.156602711727125
-0.9230456960094202
-0.5580081958147034
109
4.07
4.91
3.49
3.35
4.91
5.43
-13.158292395017726
1.4053317936201584
0.5821275199976956
110
8.39
10.89
9.09
11.57
10.16
9.41
1.735908776574546
-0.6880585340514943
-1.6928341340443394
111
1.80
0.07
1.57
0.73
1.43
1.31
-21.868497972534684
-0.44550716618040803
0.9281623696386916
112
-0.20
0.31
0.24
0.85
-0.73
0.53
-24.955246884568727
-0.21573770524173505
-0.07361651778268875
113
0.90
0.20
1.11
1.07
1.99
0.14
-22.692852050268723
-0.821790961972032
-0.21117000186167265
114
24.37
26.31
24.17
25.64
26.33
24.51
44.33486319677536
-0.08773608412210752
-1.2227959483523765
115
-0.87
1.73
-0.38
1.07
0.48
0.17
-24.553033409374308
0.5279346450261978
-1.202168374002384
116
4.08
3.51
3.31
4.53
3.71
5.39
-14.085796445122373
-0.3792123219877827
1.06634310286929
117
-1.77
0.49
-1.46
0.61
1.24
0.06
-25.976982419984576
0.09078715887656494
-1.0881677262762568
118
-0.96
-0.61
-0.38
-1.47
-1.31
0.65
-27.04706986458473
1.0305284986897507
0.5831535080432132
119
0.79
-0.70
-0.71
-0.09
1.01
-0.52
-25.30133254549241
-0.5257061002736607
0.907094061394223
120
16.52
16.57
15.64
15.62
16.36
15.94
19.379882155654503
0.3940200021081923
0.3372571022524485
121
5.44
4.63
4.01
4.51
4.62
2.83
-13.212818133458331
-0.3422665247094872
0.3021370005068221
122
16.53
16.93
17.15
16.63
14.74
16.13
19.989169667440148
-0.11028656073609916
-0.2572020360840889
123
-0.09
0.20
1.02
-1.72
-0.57
0.25
-25.344176145948815
1.491247103932886
0.18078375812716324
124
16.89
16.50
16.24
16.96
14.35
16.78
19.68615554976068
-0.4338518312644621
0.7541495043220195
125
1.53
0.42
-0.59
0.85
1.39
2.42
-22.562016712944807
0.1379760880256225
1.8671337664052652
126
7.96
8.55
8.43
9.97
8.58
8.97
-1.3218250283673956
-1.0466217782750664
-0.4878124211513389
127
10.03
7.91
11.14
7.36
7.79
8.58
-0.34940181140857085
0.10862687937590745
0.7694055188727293
128
14.59
17.72
16.23
15.97
15.86
15.95
19.045061682710227
1.0063348130753271
-1.721052464936678
129
7.30
9.90
8.18
10.04
9.06
7.72
-1.541629367844003
-0.4213316141241002
-1.9163187502542534
130
11.29
8.72
7.87
9.27
10.21
7.29
0.024538160669148747
-1.0051746932638184
1.4001323975375117
131
2.75
3.83
3.96
2.72
5.24
4.08
-14.690470110133191
0.8339303496820648
-0.6456731563548057
132
-1.82
-1.45
1.32
-0.52
0.38
-0.49
-26.276703581849297
-0.702100316318851
-1.3704398961508704
133
3.60
3.42
6.28
3.98
3.76
4.20
-13.389341244232432
-0.5042568681091175
-0.7693252233489704
134
4.04
2.86
3.96
3.82
4.37
2.35
-15.27432152014471
-1.0693169055076361
-0.10160765549842143
135
7.79
9.05
10.64
8.38
7.96
10.99
0.15434939482138468
0.8242356486783281
-0.4379598988159821
136
10.44
10.27
9.40
7.95
7.84
9.29
0.41138145150000366
1.5660045868364787
1.0836318249119128
137
8.85
8.68
8.74
9.81
9.17
9.30
-0.23385456098347604
-0.8672041425025668
0.07040657554711759
138
3.33
3.65
3.41
2.46
4.33
5.27
-14.76203607910399
1.2418426103364615
0.7261577976651439
139
3.17
3.69
3.94
4.90
3.64
4.44
-14.492040096245788
-0.7472454153799952
-0.3554304207277773
140
25.78
24.62
22.82
26.84
24.70
24.24
43.06090576252818
-2.0934403771253773
0.8530640190449735
141
3.51
3.74
4.89
3.23
3.77
4.41
-14.219173479498446
0.4324470811399057
-0.161463050867934
142
0.69
-1.29
0.23
1.02
-1.82
-1.24
-26.43999224960183
-1.831693213354897
0.6203328736254401
143
1.54
0.70
0.29
-0.69
0.55
1.85
-23.095888280598878
1.3423853860660462
1.6945760814238502
144
-0.11
0.93
-0.79
0.81
-0.04
-0.29
-25.25799241604372
0.09324852057499683
-0.23176818750229458
145
25.96
25.13
25.87
24.48
23.63
24.93
44.13126382268727
-0.013560120110352984
0.5697307650156991
146
0.74
1.57
0.94
0.91
0.65
0.12
-23.018003040893543
0.33251502325097854
-0.4888834056340321
147
16.26
14.83
16.97
13.46
17.16
15.29
18.691725905913447
0.5319082546212002
0.315668692359956
148
4.85
5.78
2.66
5.95
3.62
4.29
-13.185622830143107
-0.11364120208933785
0.3986217477892081
149
26.34
24.75
23.10
24.26
25.51
26.16
44.023783412780524
0.2646784723235609
2.274631737141466
150
4.78
3.55
2.82
2.99
4.02
3.56
-15.12786698858175
0.3735789748650763
1.3666015455092861
151
24.31
26.13
25.67
24.47
23.95
25.87
44.14429098587522
0.9867524220818551
-0.6207698350795993
152
27.23
24.66
25.13
25.14
24.40
24.49
44.57633896444414
-0.9790458542835393
1.5261397423430365
153
2.97
5.74
4.87
4.47
3.67
4.25
-13.406482169735058
0.8810999834297873
-1.5523592839831566
154
14.07
18.04
15.54
15.78
16.60
15.29
18.524621987696946
1.2587640135052143
-2.2720374918211714
155
2.74
4.53
3.67
5.55
6.33
3.48
-13.412255218059228
-0.9779399107692137
-1.8210136432035549
156
2.73
2.23
-0.83
0.75
0.95
0.92
-22.224378000701467
1.1140550254641433
1.7572689600236928
157
3.32
5.55
4.90
4.76
3.75
5.32
-12.674241816918789
0.7480192711215132
-0.9162462105724078
158
8.52
9.95
9.54
7.13
8.23
8.29
-1.1754055211095358
1.8063363815109734
-0.5570038841126583
159
1.97
0.44
0.93
-0.57
-0.18
1.71
-23.00328298093407
1.0002018242080661
1.8925696567828671
160
9.27
8.34
10.21
9.19
8.60
7.39
-0.6550100121176499
-1.1682761776088
-0.5729061998559155
161
-0.56
0.39
1.26
-0.66
-1.86
0.03
-25.782782993499634
0.8522241045239912
-0.43236851084162536
162
25.10
25.65
25.57
26.44
24.64
25.87
45.25329148621883
-0.8940552168409202
-0.3882736620636697
163
0.88
0.21
4.41
-0.45
1.32
1.54
-21.019840930140315
0.4172958804871537
-0.5602876403991484
164
22.40
25.83
25.11
23.84
24.36
25.74
42.64545451431192
1.3468283838984243
-1.7019340990043132
165
-0.12
0.54
-0.60
1.09
-1.44
0.54
-25.552024244577932
-0.1379797594353148
0.30518506635038356
166
0.05
-0.16
-0.18
-1.32
-0.01
-1.08
-26.297971097155532
0.7031490618400853
0.19069206067037017
167
-0.68
3.14
-1.02
0.77
1.04
-0.23
-24.215218043279823
1.653969576022174
-1.4738988806392768
168
8.63
9.90
10.43
7.89
8.78
8.95
0.17530397574983816
1.2425137219896765
-0.8231533416512451
169
3.41
2.09
6.91
4.79
4.46
2.87
-13.690210237391959
-2.41038377534018
-1.5080041892058509
170
-0.42
0.93
0.79
-0.73
-0.08
0.55
-24.663093311992988
1.3328005200355753
-0.4144950292758619
171
3.72
2.99
4.84
4.70
4.31
2.13
-14.751842665724274
-1.7326860851845556
-0.9996282240237604
172
24.95
24.47
26.43
25.52
26.00
24.94
45.13588195180022
-1.3622534089624452
-0.8098871533918619
173
15.92
15.79
13.99
14.69
17.84
15.78
18.170394847389378
0.596546253276191
0.7073316011160896
174
16.76
16.36
14.80
15.70
15.11
14.68
17.78874308036913
0.021289243338674227
0.6309630740832528
175
3.03
0.01
0.30
0.41
1.77
1.17
-21.955199755506452
-0.2633100985195951
2.330305847330958
176
8.18
9.33
9.66
8.89
8.78
7.48
-1.0909255222562302
-0.14753009593874397
-1.438674821359479
177
4.23
6.10
3.82
4.51
5.30
2.99
-12.931770098130619
0.7409965721778257
-1.085326190430775
178
7.76
8.79
10.10
8.35
8.29
8.56
-1.2100903470364748
0.13366583551390118
-1.1262308539912251
179
16.06
16.32
15.56
16.23
15.14
16.03
18.61050007970017
-0.1283870266231045
0.2115078809391242
180
-0.61
2.33
2.53
0.16
-0.55
2.65
-22.200692482702898
2.0007974750722126
-1.0556885443757975
181
-0.55
0.42
1.19
-0.26
-0.59
-1.92
-25.93429576761373
0.07550274838518513
-1.4515645103309671
182
0.94
1.04
2.52
2.34
0.37
2.03
-21.073941468879934
-0.7939813978736506
-0.33419954042711797
183
1.12
0.29
2.40
1.22
1.36
0.19
-22.050052889913616
-0.9451636987675922
-0.4992586824670875
184
16.65
16.43
16.35
16.62
16.62
18.20
21.24579480946268
-0.02081152998130514
0.7865196229794921
185
24.24
24.02
25.35
25.11
23.10
25.53
42.666989106272155
-0.9568592477125865
0.052233768368702645
186
7.70
7.86
11.13
9.69
9.08
9.59
0.20685954033330003
-1.3923117827977296
-1.3079643755254926
187
15.52
15.69
15.81
16.38
15.32
15.71
18.19858506109467
-0.7434372698802415
-0.25008620543357135
188
25.34
23.46
26.41
25.23
24.53
24.83
44.03298731006867
-1.800826322670656
0.10710780208452991
189
0.30
-0.50
0.74
0.31
-1.13
0.67
-25.05069123791796
-0.38281665797623676
0.6171346302798083
190
2.09
0.49
0.97
0.75
0.11
1.15
-22.598644105015612
-0.10327983324631496
1.3958306058722865
191
16.31
16.55
16.73
17.47
15.42
17.27
20.58477206756423
-0.735879785937212
8.87973835512281e-05
192
2.49
3.08
1.54
0.16
0.37
1.87
-20.6986539602996
2.2028318806672766
0.9421301288863788
193
25.95
24.45
24.63
25.04
23.77
25.21
43.51326914142924
-0.7389001357654978
1.24098232762239
194
0.29
-0.83
0.58
-1.33
0.20
0.76
-25.1005291089544
0.5764769782925557
0.9680074466210065
195
24.61
23.81
25.81
26.55
26.70
26.65
45.75851938593207
-2.174502964655344
-0.28930328972545405
196
14.09
16.30
17.44
17.19
18.35
15.33
20.19191639368224
-1.2375867685494537
-3.011573470265875
197
0.74
1.92
1.04
2.29
1.95
-0.02
-21.798659147622573
-0.5746807375429982
-1.2256576775405432
198
3.54
3.54
3.87
3.47
3.95
5.37
-14.266922087033452
0.4037763848146327
0.6171112878036471
199
1.35
0.99
0.35
1.21
1.14
1.28
-22.418243443722943
-0.046507097004556526
0.6879307654392169
200
-1.00
-1.00
-1.00
-1.00
-1.00
-1.00
0.0
0.0
0.0
form =\
html table source
{% set format="%.2f" %}
<table role=table id=pca>
<tbody role=rowgroup style="--x-min: {{df.x.min()}}; --x-max: {{df.x.max()}}; --y-min: {{df.y.min()}}; --y-max: {{df.y.max()}};
--z-min: {{df.z.min()}}; --z-max: {{df.z.max()}};">
{%- for i, (_, row) in enumerate(df.iterrows()) -%}
<tr role=row style="--x: {{row.loc['x']}}; --y: {{row.loc['y']}}; --z: {{row.loc['z']}};">
<th role=rowheader>{{i}}</th>
{%- for j in range(features) -%}
<td role=cell>{{format % row.loc[j]}}</td>
{%- endfor %}{% for j in "xyz" -%}
<td role=cell hidden>{{ row.loc[j]}}</td>
{%- endfor %}</tr>
{%- endfor %}</tbody>
</table>
form source
<form name=controls>
<script>
function rotate(axis, el){
document.getElementById("pca").style.setProperty(`--rotate-${axis}`, `${el.value}deg`);
}
</script>
<label>x
<input type=range min=0 max=360 value=350 step=5 oninput="rotate('x', this)" name="x"/>
</label>
<label>y
<input type=range min=0 max=360 value=5 step=5 oninput="rotate('y', this)" name="y"/>
</label>
<label>z
<input type=range min=0 max=360 value=15 step=5 oninput="rotate('z', this)" name="z"/>
</label>
<label>show table<input type=checkbox name=show checked onchange="document.getElementById('pca-style').setAttribute('media', this.checked ? 'screen': 'none')"/></label>
</form>
<details>
<summary>html table source</summary>
6
executed
In
[
5
]
code
%%
## styling the table
style the table using 3 d css transform , rotations , and translations .
style = \
< style id = pca - style media = screen >
. jp - RenderedHTMLCommon tbody tr : hover {
background : unset ;
}
#pca {
-- height : 600 px ;
-- width : 600 px ;
-- depth : 600 px ;
-- rotate - x : 0 deg ;
-- rotate - y : 0 deg ;
-- rotate - z : 0 deg ;
display : block ;
position : relative ;
width : var ( -- width );
height : var ( -- height );
margin - left : auto ;
margin - right : auto ;
tbody {
perspective : .3 ;
border : solid ;
position : absolute ;
display : block ;
top : 0 ;
left : 0 ;
width : var ( -- width );
height : var ( -- height );
-- dx : calc ( var ( -- x - max ) - var ( -- x - min ));
-- dy : calc ( var ( -- y - max ) - var ( -- y - min ));
-- dz : calc ( var ( -- z - max ) - var ( -- z - min ));
-- x - origin : calc ( - 1 * var ( -- x - min ) / var ( -- dx ) * var ( -- width ));
-- y - origin : calc ( var ( -- y - max ) / var ( -- dy ) * var ( -- height ));
transform - style : preserve - 3 d ;
}
tr {
top : 0 ;
left : 0 ;
position : absolute ;
display : inline - block ;
transform - origin : var ( -- x - origin ) var ( -- y - origin ) 0 ;
transform :
translateX ( var ( -- x - origin )) translateY ( var ( -- y - origin ))
rotateZ ( calc ( 360 deg - var ( -- rotate - z )))
rotateY ( calc ( 360 deg - var ( -- rotate - y )))
rotateX ( calc ( 360 deg - var ( -- rotate - x )))
translateX ( calc ( var ( -- x ) / var ( -- dx ) * var ( -- width )))
translateY ( calc ( - 1 * var ( -- y ) / var ( -- dy ) * var ( -- height )))
translateZ ( calc ( var ( -- z ) / var ( -- dz ) * var ( -- depth )))
rotateX ( var ( -- rotate - x )) rotateY ( var ( -- rotate - y )) rotateZ ( var ( -- rotate - z ));
td {
display : none ;
}
}
tr : hover , tr : focus - within {
transform :
translateX ( var ( -- x - origin )) translateY ( var ( -- y - origin ))
rotateZ ( calc ( 360 deg - var ( -- rotate - z )))
rotateY ( calc ( 360 deg - var ( -- rotate - y )))
rotateX ( calc ( 360 deg - var ( -- rotate - x )))
translateX ( calc ( var ( -- x ) / var ( -- dx ) * var ( -- width )))
translateY ( calc ( - 1 * var ( -- y ) / var ( -- dy ) * var ( -- height )))
translateZ ( calc ( var ( -- z ) / var ( -- dz ) * var ( -- depth )))
rotateX ( var ( -- rotate - x )) rotateY ( var ( -- rotate - y )) rotateZ ( var ( -- rotate - z ))
translateZ ( 10000 px );
th , td : not ([ hidden ]) {
display : unset ;
}
}
tr : last - of - type {
background - color : red ;
}
}
</ style >
...
< details open >
< summary > css with 3 d translations , transformations , and rotations </ summary >
``` html
{{ style }}
```
</ details >
... ;
metadata
91
1 outputs.
Out
[
5
]
style the table using 3d css transform, rotations, and translations.
style =\
...
css with 3d translations, transformations, and rotations
<style id=pca-style media=screen>
.jp-RenderedHTMLCommon tbody tr:hover {
background: unset;
}
#pca {
--height: 600px;
--width: 600px;
--depth: 600px;
--rotate-x: 0deg;
--rotate-y: 0deg;
--rotate-z: 0deg;
display: block;
position: relative;
width: var(--width);
height: var(--height);
margin-left: auto;
margin-right: auto;
tbody{
perspective: .3;
border: solid;
position: absolute;
display: block;
top: 0;
left: 0;
width: var(--width);
height: var(--height);
--dx: calc(var(--x-max) - var(--x-min));
--dy: calc(var(--y-max) - var(--y-min));
--dz: calc(var(--z-max) - var(--z-min));
--x-origin: calc(-1 * var(--x-min) / var(--dx) * var(--width));
--y-origin: calc(var(--y-max) / var(--dy) * var(--height));
transform-style: preserve-3d;
}
tr {
top: 0;
left: 0;
position: absolute;
display: inline-block;
transform-origin: var(--x-origin) var(--y-origin) 0;
transform:
translateX(var(--x-origin)) translateY(var(--y-origin))
rotateZ(calc(360deg - var(--rotate-z)))
rotateY(calc(360deg - var(--rotate-y)))
rotateX(calc(360deg - var(--rotate-x)))
translateX(calc(var(--x) / var(--dx) * var(--width)))
translateY(calc(-1 * var(--y) / var(--dy) * var(--height)))
translateZ(calc(var(--z) / var(--dz) * var(--depth)))
rotateX(var(--rotate-x)) rotateY(var(--rotate-y)) rotateZ(var(--rotate-z));
td {
display: none;
}
}
tr:hover, tr:focus-within {
transform:
translateX(var(--x-origin)) translateY(var(--y-origin))
rotateZ(calc(360deg - var(--rotate-z)))
rotateY(calc(360deg - var(--rotate-y)))
rotateX(calc(360deg - var(--rotate-x)))
translateX(calc(var(--x) / var(--dx) * var(--width)))
translateY(calc(-1 * var(--y) / var(--dy) * var(--height)))
translateZ(calc(var(--z) / var(--dz) * var(--depth)))
rotateX(var(--rotate-x)) rotateY(var(--rotate-y)) rotateZ(var(--rotate-z))
translateZ(10000px);
th, td:not([hidden]) {
display: unset;
}
}
tr:last-of-type {
background-color: red;
}
}
</style>
...;
7
unexecuted
In
[
None
]
code
metadata
0
Out
[
None
]
8
unexecuted
In
[
None
]
code
metadata
0
Out
[
None
]