StackGP 0.0.5__tar.gz → 0.0.7__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: StackGP
3
- Version: 0.0.5
3
+ Version: 0.0.7
4
4
  Summary: A stack-based genetic programming system
5
5
  Author-email: Nathan Haut <hautnath@msu.edu>
6
6
  Project-URL: Homepage, https://github.com/hoolagans/StackGP
@@ -20,6 +20,7 @@ from sklearn.cluster import KMeans #for clustering in ensemble definition
20
20
  from scipy.optimize import minimize #for uncertainty maximization
21
21
  from sympy import symbols, simplify, expand
22
22
  import sympy as sym
23
+ from IPython.display import display, clear_output
23
24
 
24
25
  import signal #for timing out functions
25
26
  from contextlib import contextmanager #for timing out functions
@@ -615,7 +616,7 @@ def alignGPModel(model, data, response): #Aligns a model
615
616
  setModelQuality(newModel,data,response)
616
617
  return newModel
617
618
  alignGPModel.__doc__ = "alignGPModel(model, input, response) aligns a model such that response-a*f(x)+b are minimized over a and b"
618
- def evolve(inputData, responseData, generations=100, ops=defaultOps(), const=defaultConst(), variableNames=[], mutationRate=79, crossoverRate=11, spawnRate=10, extinction=False,extinctionRate=10,elitismRate=50,popSize=300,maxComplexity=100,align=True,initialPop=[],timeLimit=300,capTime=False,tourneySize=5,tracking=False,modelEvaluationMetrics=[fitness,stackGPModelComplexity],dataSubsample=False,samplingMethod=randomSubsample,alternateObjectives=[],alternateObjFrequency=10):
619
+ def evolve(inputData, responseData, generations=100, ops=defaultOps(), const=defaultConst(), variableNames=[], mutationRate=79, crossoverRate=11, spawnRate=10, extinction=False,extinctionRate=10,elitismRate=50,popSize=300,maxComplexity=100,align=True,initialPop=[],timeLimit=300,capTime=False,tourneySize=5,tracking=False,liveTracking=False,liveTrackingInterval=1,modelEvaluationMetrics=[fitness,stackGPModelComplexity],dataSubsample=False,samplingMethod=randomSubsample,alternateObjectives=[],alternateObjFrequency=10,allowEarlyTermination=False,earlyTerminationThreshold=0):
619
620
 
620
621
  metrics=modelEvaluationMetrics
621
622
 
@@ -627,6 +628,9 @@ def evolve(inputData, responseData, generations=100, ops=defaultOps(), const=def
627
628
  models=models+initialPop
628
629
  startTime=time.perf_counter()
629
630
  bestFits=[]
631
+ if liveTracking:
632
+ fig, ax = plt.subplots(figsize=(20,10))
633
+ ckTime=time.perf_counter()
630
634
  for i in range(generations):
631
635
  if capTime and time.perf_counter()-startTime>timeLimit:
632
636
  break
@@ -639,8 +643,22 @@ def evolve(inputData, responseData, generations=100, ops=defaultOps(), const=def
639
643
  for mods in models:
640
644
  setModelQuality(mods,inData,resData,modelEvaluationMetrics=metrics)
641
645
  models=removeIndeterminateModels(models)
642
- if tracking:
646
+ if allowEarlyTermination and min([mods[2][0] for mods in models])<=earlyTerminationThreshold:
647
+ print("Early termination at generation ", i)
648
+ break
649
+ if tracking or liveTracking:
643
650
  bestFits.append(min([mods[2][0] for mods in paretoTournament(models)]))
651
+ if liveTracking and time.perf_counter()-ckTime>liveTrackingInterval:
652
+ ax.clear()
653
+ ax.plot(bestFits)
654
+ ax.set_title(f"Best Model: {bestFits[-1]:.2f} at Generation {(i+1)}")
655
+ ax.set_xlabel("Generations")
656
+ ax.set_ylabel("Fitness")
657
+ clear_output(wait=True)
658
+ display(fig)
659
+ #plt.show()
660
+ plt.close(fig)
661
+ ckTime=time.perf_counter()
644
662
 
645
663
  #paretoModels=paretoTournament(models)
646
664
  paretoModels=selectModels(models,elitismRate/100*popSize if elitismRate/100*popSize<len(models) else len(models))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: StackGP
3
- Version: 0.0.5
3
+ Version: 0.0.7
4
4
  Summary: A stack-based genetic programming system
5
5
  Author-email: Nathan Haut <hautnath@msu.edu>
6
6
  Project-URL: Homepage, https://github.com/hoolagans/StackGP
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "StackGP"
3
- version = "0.0.5"
3
+ version = "0.0.7"
4
4
  authors = [
5
5
  { name="Nathan Haut", email="hautnath@msu.edu" },
6
6
  ]
File without changes
File without changes
File without changes
File without changes