Commit 0b88d486 authored by Tiago de Freitas Pereira's avatar Tiago de Freitas Pereira
Browse files

Created functions to break down a sampleset in order to use the estimator.fit...

Created functions to break down a sampleset in order to use the estimator.fit properly and a function that transform samplesets
parent 5f566a9b
Pipeline #38124 passed with stage
in 3 minutes and 38 seconds
"""Base definition of sample"""
def samplesets_to_samples(samplesets):
"""
Given a list of :py:class:`SampleSet` break them in to a list of :py:class:`Sample` with its
corresponding key
This is supposed to fit the :py:meth:`sklearn.estimator.BaseEstimator.fit` where X and y are the inputs
Check here https://scikit-learn.org/stable/developers/develop.html for more info
Parameters
----------
samplesets: list
List of :py:class:`SampleSet
Return
------
X and y used in :py:meth:`sklearn.estimator.BaseEstimator.fit`
"""
# TODO: Is there a way to make this operation more efficient? numpy.arrays?
X = []
y= []
for s in samplesets:
X += s.samples
y += [s.key]
return X, y
def transform_sample_sets(transformer, sample_sets):
return [
SampleSet(transformer.transform(sset.samples), parent=sset)
for sset in sample_sets
]
def _copy_attributes(s, d):
"""Copies attributes from a dictionary to self
"""
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment