Skip to main content

featurefuse is Python package that allows you to choose which feature you make for machine learning models using yaml configuration.

Project description

featurefuse

featurefuse is Python package that allows you to choose which feature you make for machine learning models using yaml configuration.

This implementation is based on the below references.

How to use

  1. Implement feature engineering class inheriting Feature abstract class.
  2. Make config file.
    # Path to implemented feature class.
    use_feature:
      - .tmp.TmpFeature1
      - .tmp.TmpFeature2
    # Params for each implemented class.
    feature_params:
      TmpFeature1:
        shift_b_to: 3
      TmpFeature2:
        const: 1000
    
  3. Pass config and base/original input DataFrame to featurefuse.generator.run().
  4. You can get feature DataFrame and description of feature.

Following code is minimum example.

# Saved this code as tmp.py
import pandas as pd

from featurefuse.base import Feature


class TmpFeature1(Feature):
    def create_feature(self, tmp_df: pd.DataFrame, shift_b_to: int, **kwargs) -> pd.DataFrame:
        fe = tmp_df[["col1", "col2"]].copy(deep=True)
        self.create_description(
            f"feature col names generated by TmpFeature1", f"description of each cols of TmpFeature1"
        )
        for i in range(1, shift_b_to + 1):
            fe[f"col2_b{i}"] = fe["col2"].shift(i)
        return fe


class TmpFeature2(Feature):
    def create_feature(self, tmp_df: pd.DataFrame, const: int, **kwargs) -> pd.DataFrame:
        fe = tmp_df[["col1", "col2"]].copy(deep=True)
        self.create_description(
            f"feature col names generated by TmpFeature2", f"description of each cols of TmpFeature2"
        )
        fe[f"col2_add_{const}"] = fe["col2"] + const
        return fe


def main():
    import yaml

    from featurefuse.generator import run

    config = yaml.safe_load(
        """
    use_feature:
      # Path to TmpFeature1. In this case, this file saved as tmp.py, so path is .tmp.TmpFeature1
      - .tmp.TmpFeature1
      - .tmp.TmpFeature2
    feature_params:
      TmpFeature1:
        shift_b_to: 3
      TmpFeature2:
        const: 1000
    """
    )

    tmp_df = pd.DataFrame([["aaa", 123], ["bbb", 456], ["ccc", 789], ["ddd", 101]], columns=["col1", "col2"])
    feature, description = run(config, join_key="col1", tmp_df=tmp_df)
    print(feature)

    # you can use feature DataFrame for machine learning model etc.
    # model.fit(feature.drop("col1", axis="columns"), feature[["col1"]])


if __name__ == "__main__":
    main()

exec and then you get following output.

$ python tmp.py
  col1  col2  col2_b1  col2_b2  col2_b3  col2_add_1000
0  aaa   123      NaN      NaN      NaN           1123
1  bbb   456    123.0      NaN      NaN           1456
2  ccc   789    456.0    123.0      NaN           1789
3  ddd   101    789.0    456.0    123.0           1101

Other

This tool name is given by ChatGPT.

prompt: tell me own develop library name idea which select feature for machine learning in experiment phase.

Sure, here are a few potential names for a library that helps with feature selection for machine learning experiments:

  1. FeatureFuse
  2. Selectify
  3. FeatureCraft
  4. MachinaSelect
  5. FeatLab
  6. ModelMuse
  7. SmartFeat
  8. FeatureFlex
  9. MindFeat
  10. IntelliSelect I hope these ideas inspire you and help you find the perfect name for your library!

prompt: Which is your recommendation?

As an AI language model, I don't have personal preferences or biases, but I can provide some guidance based on the names I suggested earlier.

If you're looking for a name that highlights the library's ability to fuse or combine different features, "FeatureFuse" or "Selectify" could be good options. "FeatureCraft" and "MachinaSelect" convey a sense of precision and automation, which could be suitable if those are important qualities for your library. "FeatLab" and "ModelMuse" both sound like they could be useful tools for researchers or data scientists, while "SmartFeat" and "IntelliSelect" suggest a focus on intelligent and efficient feature selection. Finally, "MindFeat" could work if your library is designed to help researchers gain a deeper understanding of the features used in their models.

Ultimately, the name you choose will depend on your target audience and the specific features and benefits of your library. I hope this helps!

TODO

  • complete test
  • write example with hydra

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

featurefuse-0.1.2.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

featurefuse-0.1.2-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file featurefuse-0.1.2.tar.gz.

File metadata

  • Download URL: featurefuse-0.1.2.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.11

File hashes

Hashes for featurefuse-0.1.2.tar.gz
Algorithm Hash digest
SHA256 1806ae3a57e101594407599471124f5f319141ad90d8f4d9b3c71898103be77e
MD5 e9d2f8e3d1360f4ddb4df51de0e2921d
BLAKE2b-256 b651a0193b16ef0dc7a0f5362635e87936498ffeb211628d33ae50c33bc81e03

See more details on using hashes here.

File details

Details for the file featurefuse-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: featurefuse-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.11

File hashes

Hashes for featurefuse-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0c835809e6a69514fee7f759f50491723c1fc9e45424dfdb7be957e971c9b37b
MD5 a6bd5da4dabc7c32b3b36f04d2f4c2e1
BLAKE2b-256 4a23b40719baf439e07682fca07c5efa03c7021b184590438e8c3e41d054cf87

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page