updated models
This commit is contained in:
@@ -1,10 +1,45 @@
|
|||||||
from __future__ import annotations
|
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
from typing import List
|
from typing import List
|
||||||
import random
|
import random
|
||||||
|
|
||||||
|
|
||||||
class ExperientialModelOutput(BaseModel):
|
class ModelOutput(BaseModel):
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def classname(cls) -> str:
|
||||||
|
"""Return classname."""
|
||||||
|
return cls.__name__
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def list_fields(cls) -> List[str]:
|
||||||
|
"""List options that are stored as attributes."""
|
||||||
|
return list(cls.model_fields.keys())
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def from_random(cls):
|
||||||
|
"""Instantiate with random numbers."""
|
||||||
|
kwargs = {field: random.random() for field in cls.list_fields()}
|
||||||
|
return cls(**kwargs)
|
||||||
|
|
||||||
|
def __repr__(self) -> str:
|
||||||
|
model_dict = self.model_dump()
|
||||||
|
model_repr_str = f"{self.classname()}("
|
||||||
|
model_repr_str += ", ".join([f"{field}={value:.3f}" for field, value in model_dict.items()])
|
||||||
|
model_repr_str += ")"
|
||||||
|
return model_repr_str
|
||||||
|
|
||||||
|
def highest_score_field(self) -> str:
|
||||||
|
"""Return name of field with highest score."""
|
||||||
|
model_dict = self.model_dump()
|
||||||
|
return max(model_dict, key=lambda k: model_dict[k])
|
||||||
|
|
||||||
|
def highest_score_value(self) -> float:
|
||||||
|
"""Return value of field with highest score."""
|
||||||
|
model_dict = self.model_dump()
|
||||||
|
return max(model_dict.values())
|
||||||
|
|
||||||
|
|
||||||
|
class ExperientialModelOutput(ModelOutput):
|
||||||
non_transactional_action: float
|
non_transactional_action: float
|
||||||
non_transactional_reaction: float
|
non_transactional_reaction: float
|
||||||
unidirectional_transactional_action: float
|
unidirectional_transactional_action: float
|
||||||
@@ -24,34 +59,6 @@ class ExperientialModelOutput(BaseModel):
|
|||||||
symbolic_suggestive: float
|
symbolic_suggestive: float
|
||||||
symbolic_attributive: float
|
symbolic_attributive: float
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def list_fields(cls) -> List[str]:
|
|
||||||
"""List options that are stored as attributes."""
|
|
||||||
return list(cls.model_fields.keys())
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def from_random(cls) -> ExperientialModelOutput:
|
|
||||||
"""Instantiate with random numbers."""
|
|
||||||
kwargs = {field: random.random() for field in cls.list_fields()}
|
|
||||||
return ExperientialModelOutput(**kwargs)
|
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
|
||||||
model_dict = self.model_dump()
|
|
||||||
model_repr_str = "ExperientialModelOutput("
|
|
||||||
model_repr_str += ", ".join([f"{field}={value:.3f}" for field, value in model_dict.items()])
|
|
||||||
model_repr_str += ")"
|
|
||||||
return model_repr_str
|
|
||||||
|
|
||||||
def highest_score_field(self) -> str:
|
|
||||||
"""Return name of field with highest score."""
|
|
||||||
model_dict = self.model_dump()
|
|
||||||
return max(model_dict, key=lambda k: model_dict[k])
|
|
||||||
|
|
||||||
def highest_score_value(self) -> float:
|
|
||||||
"""Return value of field with highest score."""
|
|
||||||
model_dict = self.model_dump()
|
|
||||||
return max(model_dict.values())
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
m = ExperientialModelOutput.from_random()
|
m = ExperientialModelOutput.from_random()
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
from typing import List, Dict
|
from typing import List
|
||||||
import random
|
import random
|
||||||
|
|
||||||
|
|
||||||
@@ -88,35 +88,6 @@ class ModalityDepthModelOutput(ModelOutput):
|
|||||||
# modality_color: ModalityColorModelOutput
|
# modality_color: ModalityColorModelOutput
|
||||||
# modality_depth: ModalityDepthModelOutput
|
# modality_depth: ModalityDepthModelOutput
|
||||||
|
|
||||||
# @classmethod
|
|
||||||
# def list_fields(cls) -> List[str]:
|
|
||||||
# """List options that are stored as attributes."""
|
|
||||||
# return list(cls.model_fields.keys())
|
|
||||||
|
|
||||||
# @classmethod
|
|
||||||
# def from_random(cls) -> InterpersonalModelOutput:
|
|
||||||
# """Instantiate with random numbers."""
|
|
||||||
# print(cls.model_fields)
|
|
||||||
# kwargs = {field: info.annotation.from_random() for field, info in cls.model_fields.items()}
|
|
||||||
# return InterpersonalModelOutput(**kwargs)
|
|
||||||
|
|
||||||
# def __repr__(self) -> str:
|
|
||||||
# model_dict = self.model_dump()
|
|
||||||
# model_repr_str = "ExperientialModelOutput("
|
|
||||||
# model_repr_str += ", ".join([f"{field}={value:.3f}" for field, value in model_dict.items()])
|
|
||||||
# model_repr_str += ")"
|
|
||||||
# return model_repr_str
|
|
||||||
|
|
||||||
# def highest_score_field(self) -> str:
|
|
||||||
# """Return name of field with highest score."""
|
|
||||||
# model_dict = self.model_dump()
|
|
||||||
# return max(model_dict, key=lambda k: model_dict[k])
|
|
||||||
|
|
||||||
# def highest_score_value(self) -> float:
|
|
||||||
# """Return value of field with highest score."""
|
|
||||||
# model_dict = self.model_dump()
|
|
||||||
# return max(model_dict.values())
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
m = ContactModelOutput.from_random()
|
m = ContactModelOutput.from_random()
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
from typing import List, Dict
|
from typing import List
|
||||||
import random
|
import random
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user