Skip to content

Commit 2afff77

Browse files
committed
Updating.
1 parent d975fc7 commit 2afff77

6 files changed

Lines changed: 90 additions & 1 deletion

File tree

scripts/modeldata/nuc/analysis.txt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
loading modeltable.txt
2+
chosenpredictors= ['integer_count', 'float_count', 'string_count', 'backslash_count', 'nonasciibyte_count', 'object_count', 'array_count', 'null_count', 'true_count', 'false_count', 'byte_count', 'structural_indexes_count']
3+
4+
target = stage1_cycle_count
5+
0.55 cycles per byte_count
6+
R2 = 0.9952005292028262
7+
8+
target = stage2_cycle_count
9+
2 cycles per structural_indexes_count
10+
0.11 cycles per byte_count
11+
R2 = 0.9941606366930587
12+
13+
target = stage3_cycle_count
14+
14 cycles per float_count
15+
11 cycles per structural_indexes_count
16+
0.31 cycles per byte_count
17+
R2 = 0.9824350906350493
18+
19+
target = total_cycles
20+
17 cycles per float_count
21+
13 cycles per structural_indexes_count
22+
0.96 cycles per byte_count
23+
R2 = 0.991605569037089
24+

scripts/modeldata/nuc/learn.py

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import os
2+
import pandas as pd
3+
import numpy as np
4+
import matplotlib.pyplot as plt
5+
from sklearn.model_selection import train_test_split
6+
from sklearn.linear_model import LinearRegression
7+
from sklearn.linear_model import Ridge
8+
from sklearn.linear_model import Lasso
9+
from sklearn.preprocessing import normalize
10+
from sklearn import metrics
11+
12+
def displaycoefs(coef_name):
13+
coef_name.sort()
14+
coef_name.reverse()
15+
for c,n in coef_name:
16+
print("\t%0.2g cycles per %s "%(c,n))
17+
18+
datafile = "modeltable.txt" ## from ./scripts/statisticalmodel.sh
19+
20+
predictors = ["integer_count", "float_count", "string_count", "backslash_count", "nonasciibyte_count", "object_count", "array_count", "null_count", "true_count", "false_count", "byte_count", "structural_indexes_count"]
21+
targets = ["stage1_cycle_count", "stage1_instruction_count", "stage2_cycle_count", "stage2_instruction_count", "stage3_cycle_count", "stage3_instruction_count"]
22+
23+
print("loading", datafile)
24+
dataset = pd.read_csv(datafile, delim_whitespace=True, skip_blank_lines=True, comment="#", header=None, names = predictors + targets)
25+
26+
27+
dataset.columns = predictors + targets
28+
29+
dataset['total_cycles']=dataset['stage1_cycle_count']+dataset['stage2_cycle_count']+dataset['stage3_cycle_count']
30+
dataset['ratio']=dataset['total_cycles']/dataset['byte_count']
31+
#print(dataset[['ratio']])
32+
33+
chosenpredictors = predictors #["integer_count", "float_count", "string_count", "backslash_count", "nonasciibyte_count", "byte_count", "structural_indexes_count"]
34+
print("chosenpredictors=",chosenpredictors)
35+
print()
36+
chosentargets=["stage1_cycle_count", "stage2_cycle_count", "stage3_cycle_count","total_cycles"]
37+
for t in chosentargets:
38+
print("target = ", t)
39+
howmany = 1 # we want at most one predictors
40+
if(t.startswith("stage2")):
41+
howmany = 2 # we allow for less
42+
if(t.startswith("stage3")):
43+
howmany = 3 # we allow for more
44+
if(t.startswith("total")):
45+
howmany = 3 # we allow for more
46+
A=10000000.0
47+
while(True):
48+
regressor = Lasso(max_iter=100000, alpha=A, positive = True, normalize=False, fit_intercept=False) #LinearRegression(normalize=False, fit_intercept=False)
49+
x = dataset[chosenpredictors]
50+
y = dataset[[t]]
51+
regressor.fit(x, y)
52+
rest = list(filter(lambda z: z[0] != 0, zip(regressor.coef_,chosenpredictors) ))
53+
nonzero = len(rest)
54+
if(nonzero > howmany):
55+
A *= 1.2
56+
else:
57+
#print(rest)
58+
displaycoefs(rest)
59+
print("R2 = ", regressor.score(x,y))
60+
Y_pred = regressor.predict(x)
61+
break
62+
print()
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
python learn.py > analysis.txt

scripts/plots/nuc/stackedperf.pdf

23.3 KB
Binary file not shown.
23.1 KB
Binary file not shown.

scripts/refreshplot.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,7 @@
44
SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
55

66
gnuplot -e "filename='plots/skylake/parselinuxtable.txt';name='plots/skylake/stackedperf.pdf'" $SCRIPTPATH/stackbar.gnuplot
7+
gnuplot -e "filename='plots/nuc/parselinuxtable.txt';name='plots/nuc/stackedperf.pdf'" $SCRIPTPATH/stackbar.gnuplot
78

8-
echo "plots/skylake/stackedperf.pdf"
9+
echo "plots/skylake/stackedperf.pdf"
10+
echo "plots/nuc/stackedperf.pdf"

0 commit comments

Comments
 (0)