Spaces:
Sleeping
Sleeping
MilesCranmer
commited on
Commit
•
22540af
1
Parent(s):
0e65724
Fix bug with sum over empty array
Browse files- julia/sr.jl +15 -5
julia/sr.jl
CHANGED
@@ -793,7 +793,12 @@ function fullRun(niterations::Integer;
|
|
793 |
if hallOfFame.exists[size]
|
794 |
member = hallOfFame.members[size]
|
795 |
curMSE = MSE(evalTreeArray(member.tree), y)
|
796 |
-
numberSmallerAndBetter =
|
|
|
|
|
|
|
|
|
|
|
797 |
betterThanAllSmaller = (numberSmallerAndBetter == 0)
|
798 |
if betterThanAllSmaller
|
799 |
println(io, "$size|$(curMSE)|$(stringTree(member.tree))")
|
@@ -849,9 +854,9 @@ function fullRun(niterations::Integer;
|
|
849 |
@printf("Cycles per second: %.3e\n", round(num_equations/elapsed, sigdigits=3))
|
850 |
@printf("Hall of Fame:\n")
|
851 |
@printf("-----------------------------------------\n")
|
852 |
-
@printf("%-10s %-8s
|
853 |
curMSE = baselineSSE ./ len
|
854 |
-
@printf("%-10d %-
|
855 |
lastMSE = curMSE
|
856 |
lastComplexity = 0
|
857 |
|
@@ -859,13 +864,18 @@ function fullRun(niterations::Integer;
|
|
859 |
if hallOfFame.exists[size]
|
860 |
member = hallOfFame.members[size]
|
861 |
curMSE = MSE(evalTreeArray(member.tree), y)
|
862 |
-
numberSmallerAndBetter =
|
|
|
|
|
|
|
|
|
|
|
863 |
betterThanAllSmaller = (numberSmallerAndBetter == 0)
|
864 |
if betterThanAllSmaller
|
865 |
delta_c = size - lastComplexity
|
866 |
delta_l_mse = log(curMSE) - log(lastMSE)
|
867 |
score = convert(Float32, -delta_l_mse/log(delta_c))
|
868 |
-
@printf("%-10d %-
|
869 |
lastMSE = curMSE
|
870 |
lastComplexity = size
|
871 |
end
|
|
|
793 |
if hallOfFame.exists[size]
|
794 |
member = hallOfFame.members[size]
|
795 |
curMSE = MSE(evalTreeArray(member.tree), y)
|
796 |
+
numberSmallerAndBetter = 0
|
797 |
+
for i=1:(size-1)
|
798 |
+
if (hallOfFame.exists[size] && curMSE > MSE(evalTreeArray(hallOfFame.members[i].tree), y))
|
799 |
+
numberSmallerAndBetter += 1
|
800 |
+
end
|
801 |
+
end
|
802 |
betterThanAllSmaller = (numberSmallerAndBetter == 0)
|
803 |
if betterThanAllSmaller
|
804 |
println(io, "$size|$(curMSE)|$(stringTree(member.tree))")
|
|
|
854 |
@printf("Cycles per second: %.3e\n", round(num_equations/elapsed, sigdigits=3))
|
855 |
@printf("Hall of Fame:\n")
|
856 |
@printf("-----------------------------------------\n")
|
857 |
+
@printf("%-10s %-8s %-8s %-8s\n", "Complexity", "MSE", "Score", "Equation")
|
858 |
curMSE = baselineSSE ./ len
|
859 |
+
@printf("%-10d %-8.3e %-8s %-.f\n", 0, curMSE, "NaN", avgy)
|
860 |
lastMSE = curMSE
|
861 |
lastComplexity = 0
|
862 |
|
|
|
864 |
if hallOfFame.exists[size]
|
865 |
member = hallOfFame.members[size]
|
866 |
curMSE = MSE(evalTreeArray(member.tree), y)
|
867 |
+
numberSmallerAndBetter = 0
|
868 |
+
for i=1:(size-1)
|
869 |
+
if (hallOfFame.exists[size] && curMSE > MSE(evalTreeArray(hallOfFame.members[i].tree), y))
|
870 |
+
numberSmallerAndBetter += 1
|
871 |
+
end
|
872 |
+
end
|
873 |
betterThanAllSmaller = (numberSmallerAndBetter == 0)
|
874 |
if betterThanAllSmaller
|
875 |
delta_c = size - lastComplexity
|
876 |
delta_l_mse = log(curMSE) - log(lastMSE)
|
877 |
score = convert(Float32, -delta_l_mse/log(delta_c))
|
878 |
+
@printf("%-10d %-8.3e %-8.3e %-s\n" , size, curMSE, score, stringTree(member.tree))
|
879 |
lastMSE = curMSE
|
880 |
lastComplexity = size
|
881 |
end
|