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

Minor fixes #126

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Minor fixes #126

wants to merge 6 commits into from

Conversation

Roman223
Copy link
Collaborator

@Roman223 Roman223 commented Mar 12, 2025

  1. BamtLogger doesn't modify root logger. Duplicate logging from other modules (out of BAMT) should work properly.
  2. Preprocessor logic for dealing with onehot coded data (KBinsDiscretizer encode #124). Also decode function is implemented in order to make datasets for parameters learning.
  3. Tests fixed. There are multiple reason why they were failed.
  4. Type casting on predict. Some tests failed because of wrong type comparison (e.g. all(List["0.1"] == 0.1))
  5. Some issued faced during testing related to GOLEM. For some reason it returns internal golem error. These are skipped for now.
  6. Test with structure learning on 1 row is skipped as well.

Onehot usage example:

from bamt.preprocessors import Preprocessor
from sklearn import preprocessing as pp
from bamt.networks import DiscreteBN
import pandas as pd
encoder = pp.LabelEncoder()

discretizer = pp.KBinsDiscretizer(n_bins=5, encode='onehot', strategy='uniform')
preprocessor = Preprocessor([('encoder', encoder), ('discretizer', discretizer)])

df = pd.read_csv("healthcare.csv", index_col=0).iloc[:100, :]

data_coded, coder = preprocessor.apply(df)

bn = DiscreteBN()

bn.add_nodes(preprocessor.info)
bn.add_edges(data_coded)

df_ = preprocessor.decode(data_coded)
bn.fit_parameters(df_)

bn.get_info(as_df=False)

@Roman223 Roman223 self-assigned this Mar 12, 2025
@Roman223 Roman223 linked an issue Mar 12, 2025 that may be closed by this pull request
from bamt.log import logger_preprocessor
from bamt.utils import GraphUtils as gru

from pprint import pprint
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not used?

Copy link
Collaborator

@Anaxagor Anaxagor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Можешь добавить еще пожалуйста для Discrete, Logit и ConditionalLogit узлов, чтобы в функции get_dist вместе с вероятностями возвращались vals узла. Это нужно, чтобы пользователь сразу мог сопоставить эти вероятности значениям.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

KBinsDiscretizer encode
3 participants