StackGP 0.0.11__tar.gz → 0.0.13__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.11
3
+ Version: 0.0.13
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
@@ -576,16 +576,18 @@ removeIndeterminateModels.__doc__ = "removeIndeterminateModels(models) removes m
576
576
  def sortModels(models):
577
577
  return sorted(models, key=lambda m:m[2])
578
578
  sortModels.__doc__ = "sortModels(models) sorts a model population by the models' accuracies"
579
- def selectModels(models, selectionSize=0.5):
579
+ def selectModels(models, selectionSize=0.5, thresholds=None):
580
580
  tMods=copy.deepcopy(models)
581
581
  [modelToListForm(mod) for mod in tMods]
582
+ if thresholds is not None:
583
+ tMods=[mod for mod in tMods if all([mod[2][i]<=thresholds[i] for i in range(len(thresholds))])]
582
584
  paretoModels=[]
583
585
  if selectionSize<=1:
584
586
  selection=selectionSize*len(models)
585
587
  else:
586
588
  selection=selectionSize
587
589
 
588
- while len(paretoModels)<selection:
590
+ while len(paretoModels)<selection and len(tMods)>0:
589
591
  front=paretoTournament(tMods)
590
592
  paretoModels=paretoModels+front
591
593
  for i in front:
@@ -812,8 +814,19 @@ def uncertainty(data,trim=0.3):
812
814
  return h
813
815
  else:
814
816
  return 0
815
-
817
+
816
818
  def evaluateModelEnsemble(ensemble, inputData):
819
+ responses=[evaluateGPModel(mod, inputData) for mod in ensemble]
820
+ if type(responses[0])==np.ndarray:
821
+ responses=np.transpose(responses)
822
+ predictions=[np.median(res) for res in responses]
823
+ else:
824
+
825
+ predictions=[np.median(responses)]
826
+
827
+ return predictions
828
+
829
+ def evaluateModelEnsembleUncertainty(ensemble, inputData):
817
830
  responses=[evaluateGPModel(mod, inputData) for mod in ensemble]
818
831
  if type(responses[0])==np.ndarray:
819
832
  responses=np.transpose(responses)
@@ -821,10 +834,10 @@ def evaluateModelEnsemble(ensemble, inputData):
821
834
  else:
822
835
 
823
836
  uncertainties=[uncertainty(responses,0)]
824
-
825
837
  return uncertainties
838
+
826
839
  def relativeEnsembleUncertainty(ensemble,inputData):
827
- output=evaluateModelEnsemble(ensemble,inputData)
840
+ output=evaluateModelEnsembleUncertainty(ensemble,inputData)
828
841
  return np.array(output)
829
842
 
830
843
  def createUncertaintyFunc(ensemble):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: StackGP
3
- Version: 0.0.11
3
+ Version: 0.0.13
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.11"
3
+ version = "0.0.13"
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