Giter Club home page Giter Club logo

Comments (5)

yashlamba avatar yashlamba commented on July 27, 2024

async def features(self, features: Features):
'''
Converts repos into training data
'''
cols: Dict[str, Any] = {}
for feature in features:
col = self.feature_feature_column(feature)
if not col is None:
cols[feature.NAME] = col
return cols
def feature_feature_column(self, feature: Feature):
'''
Creates a feature column for a feature
'''
dtype = feature.dtype()
if not inspect.isclass(dtype):
LOGGER.warning('Unknown dtype %r. Cound not create column' % (dtype))
return None
if dtype is int or issubclass(dtype, int) \
or dtype is float or issubclass(dtype, float):
return tensorflow.feature_column.numeric_column(feature.NAME,
shape=feature.length())
LOGGER.warning('Unknown dtype %r. Cound not create column' % (dtype))
return None
def model_dir_path(self, features: Features):
'''
Creates the path to the model dir by using the provided model dir and
the sha384 hash of the concatenated feature names.
'''
if self.parent.config.directory is None:
return None
model = hashlib.sha384(''.join(features.names()).encode('utf-8'))\
.hexdigest()
if not os.path.isdir(self.parent.config.directory):
raise NotADirectoryError('%s is not a directory' % (self.parent.config.directory))
return os.path.join(self.parent.config.directory, model)

@pdxjohnny I was implementing applicable features and found it leaded to the following functions. Do they need to be re-implemented or can I pick them up from dnn and change the conditions (for starters the feature length should be 2 and so on)

from dffml.

yashlamba avatar yashlamba commented on July 27, 2024

And can you suggest me how to debug my code like how can I go about testing (for now checking that whether I have received data successfully or not)?

from dffml.

pdxjohnny avatar pdxjohnny commented on July 27, 2024

Here's an outline for 2.a.iv and 2.a.v from https://docs.google.com/document/d/16u9Tev3O0CcUDe2nfikHmrO3Xnd4ASJ45myFgQLpvzM/edit#heading=h.s3lkoesyhz9v

Is this what you're talking about?

class SimpleLinearRegression(Model):
    async def applicable_features(self, features):
        if len(features) != 1:
            raise ValueError("simple LR only supports a single feature")
        if features[0].dtype() != int and features[0].dtype() != float:
            raise ValueError("simple LR only supports int or float feature")
        if features[0].length() != 1:
            raise ValueError("simple LR only supports single values (non-matrix / array)")
        features_we_care_about = [features[0].NAME]
        return features_we_care_about

    async def train(self, sources, features):
        features_we_care_about = self.applicable_features(features)
        async for repo in sources.with_features(features_we_care_about):
            # Grab a subset of the feature data being stored within the repo
            # The subset is the feature_we_care_about and the feature we are want to predict
            feature_data = repo.features(features_we_care_about + [self.parent.config.predict])
            xData.append(feature_data[features_we_care_about[0]])
            yData.append(feature_data[self.parent.config.predict])

from dffml.

yashlamba avatar yashlamba commented on July 27, 2024

Here's an outline for 2.a.iv and 2.a.v from https://docs.google.com/document/d/16u9Tev3O0CcUDe2nfikHmrO3Xnd4ASJ45myFgQLpvzM/edit#heading=h.s3lkoesyhz9v

Is this what you're talking about?

class SimpleLinearRegression(Model):
    async def applicable_features(self, features):
        if len(features) != 1:
            raise ValueError("simple LR only supports a single feature")
        if features[0].dtype() != int and features[0].dtype() != float:
            raise ValueError("simple LR only supports int or float feature")
        if features[0].length() != 1:
            raise ValueError("simple LR only supports single values (non-matrix / array)")
        features_we_care_about = [features[0].NAME]
        return features_we_care_about

    async def train(self, sources, features):
        features_we_care_about = self.applicable_features(features)
        async for repo in sources.with_features(features_we_care_about):
            # Grab a subset of the feature data being stored within the repo
            # The subset is the feature_we_care_about and the feature we are want to predict
            feature_data = repo.features(features_we_care_about + [self.parent.config.predict])
            xData.append(feature_data[features_we_care_about[0]])
            yData.append(feature_data[self.parent.config.predict])

well, this is pretty simple and understandable, I was using dnn as my reference wherein applicable features lead to self.features which in turn lead to feature_feature_column (which ultimately checked the types).

from dffml.

pdxjohnny avatar pdxjohnny commented on July 27, 2024

ya dnn is complicated by tensorflow APIs :)

from dffml.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.