Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better NaN handling and dataframe support #200

Merged
merged 15 commits into from
Aug 27, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
added class docstrings
JannisHoch committed Aug 26, 2024
commit 633175617eeeb64d07927ace6cbd2d236d4fe19d
7 changes: 7 additions & 0 deletions copro/machine_learning.py
Original file line number Diff line number Diff line change
@@ -17,6 +17,13 @@ def __init__(
ensemble.RandomForestClassifier, ensemble.RandomForestRegressor
],
) -> None:
"""Class for all ML related stuff.
Embedded in more top-level `models.MainModel()` class.

Args:
config (dict): Parsed configuration-settings of the model.
estimator (Union[ ensemble.RandomForestClassifier, ensemble.RandomForestRegressor ]): ML model.
"""
self.config = config
self.scaler = define_scaling(config)
self.estimator = estimator
1 change: 1 addition & 0 deletions copro/models.py
Original file line number Diff line number Diff line change
@@ -26,6 +26,7 @@ def __init__(
verbose=0,
):
"""Constructor for the MainModel class.
Under the hood, the class uses the `machine_learning.MachineLearning()` class to run the computations.

Args:
X (np.ndarray, pd.DataFrame): array containing the variable values plus IDs and geometry information.
9 changes: 8 additions & 1 deletion copro/xydata.py
Original file line number Diff line number Diff line change
@@ -9,7 +9,14 @@


class XYData:
def __init__(self, config: dict, target_var: str):
def __init__(self, config: dict, target_var: Union[str, None]):
"""Collects feature (X) and target (Y) data for the model.

Args:
config (dict): Parsed configuration-settings of the model.
target_var (Union[str, None]): Target variable of the ML model. Either a string or None. \
Can be `None` for classification models, but needs to be specified for regression models.
"""
self.XY_dict = {}
self.__XY_dict_initiated__ = False
self.config = config