partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
SGMLBaseValidator.save
Save validator object to pickle.
ml_tools/eolearn/ml_tools/validator.py
def save(self, filename): """ Save validator object to pickle. """ with open(filename, 'wb') as output: pickle.dump(self, output, protocol=pickle.HIGHEST_PROTOCOL)
def save(self, filename): """ Save validator object to pickle. """ with open(filename, 'wb') as output: pickle.dump(self, output, protocol=pickle.HIGHEST_PROTOCOL)
[ "Save", "validator", "object", "to", "pickle", "." ]
sentinel-hub/eo-learn
python
https://github.com/sentinel-hub/eo-learn/blob/b8c390b9f553c561612fe9eb64e720611633a035/ml_tools/eolearn/ml_tools/validator.py#L156-L161
[ "def", "save", "(", "self", ",", "filename", ")", ":", "with", "open", "(", "filename", ",", "'wb'", ")", "as", "output", ":", "pickle", ".", "dump", "(", "self", ",", "output", ",", "protocol", "=", "pickle", ".", "HIGHEST_PROTOCOL", ")" ]
b8c390b9f553c561612fe9eb64e720611633a035
train
SGMLBaseValidator.pandas_df
Returns pandas DataFrame containing pixel counts for all truth classes, classified classes (for each truth class), and file name of the input EODataSet. The data frame thus contains N = self.n_validation_sets rows and M = len(self.truth_classes) + len(self.truth_clas...
ml_tools/eolearn/ml_tools/validator.py
def pandas_df(self): """ Returns pandas DataFrame containing pixel counts for all truth classes, classified classes (for each truth class), and file name of the input EODataSet. The data frame thus contains N = self.n_validation_sets rows and M = len(...
def pandas_df(self): """ Returns pandas DataFrame containing pixel counts for all truth classes, classified classes (for each truth class), and file name of the input EODataSet. The data frame thus contains N = self.n_validation_sets rows and M = len(...
[ "Returns", "pandas", "DataFrame", "containing", "pixel", "counts", "for", "all", "truth", "classes", "classified", "classes", "(", "for", "each", "truth", "class", ")", "and", "file", "name", "of", "the", "input", "EODataSet", "." ]
sentinel-hub/eo-learn
python
https://github.com/sentinel-hub/eo-learn/blob/b8c390b9f553c561612fe9eb64e720611633a035/ml_tools/eolearn/ml_tools/validator.py#L163-L193
[ "def", "pandas_df", "(", "self", ")", ":", "if", "self", ".", "val_df", "is", "not", "None", ":", "return", "self", ".", "val_df", "clf", "=", "self", ".", "pixel_classification_counts", ".", "reshape", "(", "self", ".", "pixel_classification_counts", ".", ...
b8c390b9f553c561612fe9eb64e720611633a035
train
SGMLBaseValidator.confusion_matrix
Returns the normalised confusion matrix
ml_tools/eolearn/ml_tools/validator.py
def confusion_matrix(self): """ Returns the normalised confusion matrix """ confusion_matrix = self.pixel_classification_sum.astype(np.float) confusion_matrix = np.divide(confusion_matrix.T, self.pixel_truth_sum.T).T return confusion_matrix * 100.0
def confusion_matrix(self): """ Returns the normalised confusion matrix """ confusion_matrix = self.pixel_classification_sum.astype(np.float) confusion_matrix = np.divide(confusion_matrix.T, self.pixel_truth_sum.T).T return confusion_matrix * 100.0
[ "Returns", "the", "normalised", "confusion", "matrix" ]
sentinel-hub/eo-learn
python
https://github.com/sentinel-hub/eo-learn/blob/b8c390b9f553c561612fe9eb64e720611633a035/ml_tools/eolearn/ml_tools/validator.py#L201-L208
[ "def", "confusion_matrix", "(", "self", ")", ":", "confusion_matrix", "=", "self", ".", "pixel_classification_sum", ".", "astype", "(", "np", ".", "float", ")", "confusion_matrix", "=", "np", ".", "divide", "(", "confusion_matrix", ".", "T", ",", "self", "."...
b8c390b9f553c561612fe9eb64e720611633a035
train
SGMLBaseValidator.plot_confusion_matrix
Plots the confusion matrix.
ml_tools/eolearn/ml_tools/validator.py
def plot_confusion_matrix(self, normalised=True): """ Plots the confusion matrix. """ conf_matrix = self.confusion_matrix() if normalised: sns.heatmap(conf_matrix, annot=True, annot_kws={"size": 12}, fmt='2.1f', cmap='YlGnBu', vmin=0.0, ...
def plot_confusion_matrix(self, normalised=True): """ Plots the confusion matrix. """ conf_matrix = self.confusion_matrix() if normalised: sns.heatmap(conf_matrix, annot=True, annot_kws={"size": 12}, fmt='2.1f', cmap='YlGnBu', vmin=0.0, ...
[ "Plots", "the", "confusion", "matrix", "." ]
sentinel-hub/eo-learn
python
https://github.com/sentinel-hub/eo-learn/blob/b8c390b9f553c561612fe9eb64e720611633a035/ml_tools/eolearn/ml_tools/validator.py#L210-L227
[ "def", "plot_confusion_matrix", "(", "self", ",", "normalised", "=", "True", ")", ":", "conf_matrix", "=", "self", ".", "confusion_matrix", "(", ")", "if", "normalised", ":", "sns", ".", "heatmap", "(", "conf_matrix", ",", "annot", "=", "True", ",", "annot...
b8c390b9f553c561612fe9eb64e720611633a035
train
SGMLBaseValidator.summary
Prints out the summary of validation for giving scoring function.
ml_tools/eolearn/ml_tools/validator.py
def summary(self, scoring): """ Prints out the summary of validation for giving scoring function. """ if scoring == 'class_confusion': print('*' * 50) print(' Confusion Matrix ') print('x-axis: ' + ' | '.join(list(self.class_dictionary.keys()))) ...
def summary(self, scoring): """ Prints out the summary of validation for giving scoring function. """ if scoring == 'class_confusion': print('*' * 50) print(' Confusion Matrix ') print('x-axis: ' + ' | '.join(list(self.class_dictionary.keys()))) ...
[ "Prints", "out", "the", "summary", "of", "validation", "for", "giving", "scoring", "function", "." ]
sentinel-hub/eo-learn
python
https://github.com/sentinel-hub/eo-learn/blob/b8c390b9f553c561612fe9eb64e720611633a035/ml_tools/eolearn/ml_tools/validator.py#L229-L239
[ "def", "summary", "(", "self", ",", "scoring", ")", ":", "if", "scoring", "==", "'class_confusion'", ":", "print", "(", "'*'", "*", "50", ")", "print", "(", "' Confusion Matrix '", ")", "print", "(", "'x-axis: '", "+", "' | '", ".", "join", "(", "list",...
b8c390b9f553c561612fe9eb64e720611633a035
train
SimpleFilterTask.execute
:param eopatch: Input EOPatch. :type eopatch: EOPatch :return: Transformed eo patch :rtype: EOPatch
features/eolearn/features/feature_manipulation.py
def execute(self, eopatch): """ :param eopatch: Input EOPatch. :type eopatch: EOPatch :return: Transformed eo patch :rtype: EOPatch """ feature_type, feature_name = next(self.feature(eopatch)) good_idxs = self._get_filtered_indices(eopatch[feature_type][f...
def execute(self, eopatch): """ :param eopatch: Input EOPatch. :type eopatch: EOPatch :return: Transformed eo patch :rtype: EOPatch """ feature_type, feature_name = next(self.feature(eopatch)) good_idxs = self._get_filtered_indices(eopatch[feature_type][f...
[ ":", "param", "eopatch", ":", "Input", "EOPatch", ".", ":", "type", "eopatch", ":", "EOPatch", ":", "return", ":", "Transformed", "eo", "patch", ":", "rtype", ":", "EOPatch" ]
sentinel-hub/eo-learn
python
https://github.com/sentinel-hub/eo-learn/blob/b8c390b9f553c561612fe9eb64e720611633a035/features/eolearn/features/feature_manipulation.py#L44-L69
[ "def", "execute", "(", "self", ",", "eopatch", ")", ":", "feature_type", ",", "feature_name", "=", "next", "(", "self", ".", "feature", "(", "eopatch", ")", ")", "good_idxs", "=", "self", ".", "_get_filtered_indices", "(", "eopatch", "[", "feature_type", "...
b8c390b9f553c561612fe9eb64e720611633a035
train
HOGTask.execute
Execute computation of HoG features on input eopatch :param eopatch: Input eopatch :type eopatch: eolearn.core.EOPatch :return: EOPatch instance with new keys holding the HoG features and HoG image for visualisation. :rtype: eolearn.core.EOPatch
features/eolearn/features/hog.py
def execute(self, eopatch): """ Execute computation of HoG features on input eopatch :param eopatch: Input eopatch :type eopatch: eolearn.core.EOPatch :return: EOPatch instance with new keys holding the HoG features and HoG image for visualisation. :rtype: eolear...
def execute(self, eopatch): """ Execute computation of HoG features on input eopatch :param eopatch: Input eopatch :type eopatch: eolearn.core.EOPatch :return: EOPatch instance with new keys holding the HoG features and HoG image for visualisation. :rtype: eolear...
[ "Execute", "computation", "of", "HoG", "features", "on", "input", "eopatch" ]
sentinel-hub/eo-learn
python
https://github.com/sentinel-hub/eo-learn/blob/b8c390b9f553c561612fe9eb64e720611633a035/features/eolearn/features/hog.py#L80-L94
[ "def", "execute", "(", "self", ",", "eopatch", ")", ":", "for", "feature_type", ",", "feature_name", ",", "new_feature_name", "in", "self", ".", "feature", ":", "result", "=", "self", ".", "_compute_hog", "(", "eopatch", "[", "feature_type", "]", "[", "fea...
b8c390b9f553c561612fe9eb64e720611633a035
train
LocalBinaryPatternTask.execute
Execute computation of local binary patterns on input eopatch :param eopatch: Input eopatch :type eopatch: eolearn.core.EOPatch :return: EOPatch instance with new key holding the LBP image. :rtype: eolearn.core.EOPatch
features/eolearn/features/local_binary_pattern.py
def execute(self, eopatch): """ Execute computation of local binary patterns on input eopatch :param eopatch: Input eopatch :type eopatch: eolearn.core.EOPatch :return: EOPatch instance with new key holding the LBP image. :rtype: eolearn.core.EOPatch """ ...
def execute(self, eopatch): """ Execute computation of local binary patterns on input eopatch :param eopatch: Input eopatch :type eopatch: eolearn.core.EOPatch :return: EOPatch instance with new key holding the LBP image. :rtype: eolearn.core.EOPatch """ ...
[ "Execute", "computation", "of", "local", "binary", "patterns", "on", "input", "eopatch" ]
sentinel-hub/eo-learn
python
https://github.com/sentinel-hub/eo-learn/blob/b8c390b9f553c561612fe9eb64e720611633a035/features/eolearn/features/local_binary_pattern.py#L48-L59
[ "def", "execute", "(", "self", ",", "eopatch", ")", ":", "for", "feature_type", ",", "feature_name", ",", "new_feature_name", "in", "self", ".", "feature", ":", "eopatch", "[", "feature_type", "]", "[", "new_feature_name", "]", "=", "self", ".", "_compute_lb...
b8c390b9f553c561612fe9eb64e720611633a035
train
ransac
Fit model parameters to data using the RANSAC algorithm This implementation is written from pseudo-code found at http://en.wikipedia.org/w/index.php?title=RANSAC&oldid=116358182 :param npts: A set of observed data points :param model: A model that can be fitted to data points :param n: The minimum...
coregistration/eolearn/coregistration/coregistration_utilities.py
def ransac(npts, model, n, k, t, d): """ Fit model parameters to data using the RANSAC algorithm This implementation is written from pseudo-code found at http://en.wikipedia.org/w/index.php?title=RANSAC&oldid=116358182 :param npts: A set of observed data points :param model: A model that can be fi...
def ransac(npts, model, n, k, t, d): """ Fit model parameters to data using the RANSAC algorithm This implementation is written from pseudo-code found at http://en.wikipedia.org/w/index.php?title=RANSAC&oldid=116358182 :param npts: A set of observed data points :param model: A model that can be fi...
[ "Fit", "model", "parameters", "to", "data", "using", "the", "RANSAC", "algorithm" ]
sentinel-hub/eo-learn
python
https://github.com/sentinel-hub/eo-learn/blob/b8c390b9f553c561612fe9eb64e720611633a035/coregistration/eolearn/coregistration/coregistration_utilities.py#L14-L53
[ "def", "ransac", "(", "npts", ",", "model", ",", "n", ",", "k", ",", "t", ",", "d", ")", ":", "iterations", "=", "0", "bestfit", "=", "None", "besterr", "=", "np", ".", "inf", "# best_inlier_idxs = None", "while", "iterations", "<", "k", ":", "maybe_...
b8c390b9f553c561612fe9eb64e720611633a035
train
random_partition
return n random rows of data (and also the other len(data)-n rows)
coregistration/eolearn/coregistration/coregistration_utilities.py
def random_partition(n, n_data): """return n random rows of data (and also the other len(data)-n rows)""" all_idxs = np.arange(n_data) np.random.shuffle(all_idxs) idxs1 = all_idxs[:n] idxs2 = all_idxs[n:] return idxs1, idxs2
def random_partition(n, n_data): """return n random rows of data (and also the other len(data)-n rows)""" all_idxs = np.arange(n_data) np.random.shuffle(all_idxs) idxs1 = all_idxs[:n] idxs2 = all_idxs[n:] return idxs1, idxs2
[ "return", "n", "random", "rows", "of", "data", "(", "and", "also", "the", "other", "len", "(", "data", ")", "-", "n", "rows", ")" ]
sentinel-hub/eo-learn
python
https://github.com/sentinel-hub/eo-learn/blob/b8c390b9f553c561612fe9eb64e720611633a035/coregistration/eolearn/coregistration/coregistration_utilities.py#L56-L62
[ "def", "random_partition", "(", "n", ",", "n_data", ")", ":", "all_idxs", "=", "np", ".", "arange", "(", "n_data", ")", "np", ".", "random", ".", "shuffle", "(", "all_idxs", ")", "idxs1", "=", "all_idxs", "[", ":", "n", "]", "idxs2", "=", "all_idxs",...
b8c390b9f553c561612fe9eb64e720611633a035
train
EstimateEulerTransformModel.estimate_rigid_transformation
Estimate rigid transformation given a set of indices :param idx: Array of indices used to estimate the transformation :return: Estimated transformation matrix
coregistration/eolearn/coregistration/coregistration_utilities.py
def estimate_rigid_transformation(self, idx): """ Estimate rigid transformation given a set of indices :param idx: Array of indices used to estimate the transformation :return: Estimated transformation matrix """ # Look at points of given indices only src_pts = self.src_...
def estimate_rigid_transformation(self, idx): """ Estimate rigid transformation given a set of indices :param idx: Array of indices used to estimate the transformation :return: Estimated transformation matrix """ # Look at points of given indices only src_pts = self.src_...
[ "Estimate", "rigid", "transformation", "given", "a", "set", "of", "indices" ]
sentinel-hub/eo-learn
python
https://github.com/sentinel-hub/eo-learn/blob/b8c390b9f553c561612fe9eb64e720611633a035/coregistration/eolearn/coregistration/coregistration_utilities.py#L80-L106
[ "def", "estimate_rigid_transformation", "(", "self", ",", "idx", ")", ":", "# Look at points of given indices only", "src_pts", "=", "self", ".", "src_pts", "[", "idx", ",", ":", "]", "trg_pts", "=", "self", ".", "trg_pts", "[", "idx", ",", ":", "]", "# Get ...
b8c390b9f553c561612fe9eb64e720611633a035
train
EstimateEulerTransformModel.score
Estimate the registration error of estimated transformation matrix :param idx: List of points used to estimate the transformation :param warp_matrix: Matrix estimating Euler trasnformation :return: Square root of Target Registration Error
coregistration/eolearn/coregistration/coregistration_utilities.py
def score(self, idx, warp_matrix): """ Estimate the registration error of estimated transformation matrix :param idx: List of points used to estimate the transformation :param warp_matrix: Matrix estimating Euler trasnformation :return: Square root of Target Registration Error "...
def score(self, idx, warp_matrix): """ Estimate the registration error of estimated transformation matrix :param idx: List of points used to estimate the transformation :param warp_matrix: Matrix estimating Euler trasnformation :return: Square root of Target Registration Error "...
[ "Estimate", "the", "registration", "error", "of", "estimated", "transformation", "matrix" ]
sentinel-hub/eo-learn
python
https://github.com/sentinel-hub/eo-learn/blob/b8c390b9f553c561612fe9eb64e720611633a035/coregistration/eolearn/coregistration/coregistration_utilities.py#L117-L128
[ "def", "score", "(", "self", ",", "idx", ",", "warp_matrix", ")", ":", "# Transform source points with estimated transformation", "trg_fit", "=", "scipy", ".", "dot", "(", "warp_matrix", ",", "np", ".", "concatenate", "(", "(", "self", ".", "src_pts", "[", "id...
b8c390b9f553c561612fe9eb64e720611633a035
train
rolling_window
Create a view of `array` which for every point gives the n-dimensional neighbourhood of size window. New dimensions are added at the end of `array` or after the corresponding original dimension. Parameters ---------- array : array_like Array to which the rolling window is applied. ...
ml_tools/eolearn/ml_tools/utilities.py
def rolling_window(array, window=(0,), asteps=None, wsteps=None, axes=None, toend=True): """Create a view of `array` which for every point gives the n-dimensional neighbourhood of size window. New dimensions are added at the end of `array` or after the corresponding original dimension. Parameters ...
def rolling_window(array, window=(0,), asteps=None, wsteps=None, axes=None, toend=True): """Create a view of `array` which for every point gives the n-dimensional neighbourhood of size window. New dimensions are added at the end of `array` or after the corresponding original dimension. Parameters ...
[ "Create", "a", "view", "of", "array", "which", "for", "every", "point", "gives", "the", "n", "-", "dimensional", "neighbourhood", "of", "size", "window", ".", "New", "dimensions", "are", "added", "at", "the", "end", "of", "array", "or", "after", "the", "...
sentinel-hub/eo-learn
python
https://github.com/sentinel-hub/eo-learn/blob/b8c390b9f553c561612fe9eb64e720611633a035/ml_tools/eolearn/ml_tools/utilities.py#L17-L186
[ "def", "rolling_window", "(", "array", ",", "window", "=", "(", "0", ",", ")", ",", "asteps", "=", "None", ",", "wsteps", "=", "None", ",", "axes", "=", "None", ",", "toend", "=", "True", ")", ":", "# pylint: disable=too-many-branches\r", "# pylint: disabl...
b8c390b9f553c561612fe9eb64e720611633a035
train
RegistrationTask.execute
Method that estimates registrations and warps EOPatch objects
coregistration/eolearn/coregistration/coregistration.py
def execute(self, eopatch): """ Method that estimates registrations and warps EOPatch objects """ self.check_params() self.get_params() new_eopatch = copy.deepcopy(eopatch) f_type, f_name = next(self.registration_feature(eopatch)) sliced_data = copy.deepcopy(eop...
def execute(self, eopatch): """ Method that estimates registrations and warps EOPatch objects """ self.check_params() self.get_params() new_eopatch = copy.deepcopy(eopatch) f_type, f_name = next(self.registration_feature(eopatch)) sliced_data = copy.deepcopy(eop...
[ "Method", "that", "estimates", "registrations", "and", "warps", "EOPatch", "objects" ]
sentinel-hub/eo-learn
python
https://github.com/sentinel-hub/eo-learn/blob/b8c390b9f553c561612fe9eb64e720611633a035/coregistration/eolearn/coregistration/coregistration.py#L117-L159
[ "def", "execute", "(", "self", ",", "eopatch", ")", ":", "self", ".", "check_params", "(", ")", "self", ".", "get_params", "(", ")", "new_eopatch", "=", "copy", ".", "deepcopy", "(", "eopatch", ")", "f_type", ",", "f_name", "=", "next", "(", "self", ...
b8c390b9f553c561612fe9eb64e720611633a035
train
RegistrationTask.warp
Function to warp input image given an estimated 2D linear transformation :param warp_matrix: Linear 2x3 matrix to use to linearly warp the input images :type warp_matrix: ndarray :param img: Image to be warped with estimated transformation :type img: ndarray :param iflag: Interp...
coregistration/eolearn/coregistration/coregistration.py
def warp(self, warp_matrix, img, iflag=cv2.INTER_NEAREST): """ Function to warp input image given an estimated 2D linear transformation :param warp_matrix: Linear 2x3 matrix to use to linearly warp the input images :type warp_matrix: ndarray :param img: Image to be warped with estimated...
def warp(self, warp_matrix, img, iflag=cv2.INTER_NEAREST): """ Function to warp input image given an estimated 2D linear transformation :param warp_matrix: Linear 2x3 matrix to use to linearly warp the input images :type warp_matrix: ndarray :param img: Image to be warped with estimated...
[ "Function", "to", "warp", "input", "image", "given", "an", "estimated", "2D", "linear", "transformation" ]
sentinel-hub/eo-learn
python
https://github.com/sentinel-hub/eo-learn/blob/b8c390b9f553c561612fe9eb64e720611633a035/coregistration/eolearn/coregistration/coregistration.py#L161-L188
[ "def", "warp", "(", "self", ",", "warp_matrix", ",", "img", ",", "iflag", "=", "cv2", ".", "INTER_NEAREST", ")", ":", "height", ",", "width", "=", "img", ".", "shape", "[", ":", "2", "]", "warped_img", "=", "np", ".", "zeros_like", "(", "img", ",",...
b8c390b9f553c561612fe9eb64e720611633a035
train
RegistrationTask.is_registration_suspicious
Static method that check if estimated linear transformation could be unplausible This function checks whether the norm of the estimated translation or the rotation angle exceed predefined values. For the translation, a maximum translation radius of 20 pixels is flagged, while larger rotations than ...
coregistration/eolearn/coregistration/coregistration.py
def is_registration_suspicious(warp_matrix): """ Static method that check if estimated linear transformation could be unplausible This function checks whether the norm of the estimated translation or the rotation angle exceed predefined values. For the translation, a maximum translation radius ...
def is_registration_suspicious(warp_matrix): """ Static method that check if estimated linear transformation could be unplausible This function checks whether the norm of the estimated translation or the rotation angle exceed predefined values. For the translation, a maximum translation radius ...
[ "Static", "method", "that", "check", "if", "estimated", "linear", "transformation", "could", "be", "unplausible" ]
sentinel-hub/eo-learn
python
https://github.com/sentinel-hub/eo-learn/blob/b8c390b9f553c561612fe9eb64e720611633a035/coregistration/eolearn/coregistration/coregistration.py#L191-L208
[ "def", "is_registration_suspicious", "(", "warp_matrix", ")", ":", "if", "warp_matrix", "is", "None", ":", "return", "1", "cos_theta", "=", "np", ".", "trace", "(", "warp_matrix", "[", ":", "2", ",", ":", "2", "]", ")", "/", "2", "rot_angle", "=", "np"...
b8c390b9f553c561612fe9eb64e720611633a035
train
ThunderRegistration.register
Implementation of pair-wise registration using thunder-registration For more information on the model estimation, refer to https://github.com/thunder-project/thunder-registration This function takes two 2D single channel images and estimates a 2D translation that best aligns the pair. The estim...
coregistration/eolearn/coregistration/coregistration.py
def register(self, src, trg, trg_mask=None, src_mask=None): """ Implementation of pair-wise registration using thunder-registration For more information on the model estimation, refer to https://github.com/thunder-project/thunder-registration This function takes two 2D single channel images and...
def register(self, src, trg, trg_mask=None, src_mask=None): """ Implementation of pair-wise registration using thunder-registration For more information on the model estimation, refer to https://github.com/thunder-project/thunder-registration This function takes two 2D single channel images and...
[ "Implementation", "of", "pair", "-", "wise", "registration", "using", "thunder", "-", "registration" ]
sentinel-hub/eo-learn
python
https://github.com/sentinel-hub/eo-learn/blob/b8c390b9f553c561612fe9eb64e720611633a035/coregistration/eolearn/coregistration/coregistration.py#L215-L242
[ "def", "register", "(", "self", ",", "src", ",", "trg", ",", "trg_mask", "=", "None", ",", "src_mask", "=", "None", ")", ":", "# Initialise instance of CrossCorr object", "ccreg", "=", "registration", ".", "CrossCorr", "(", ")", "# padding_value = 0", "# Compute...
b8c390b9f553c561612fe9eb64e720611633a035
train
ECCRegistration.register
Implementation of pair-wise registration and warping using Enhanced Correlation Coefficient This function estimates an Euclidean transformation (x,y translation + rotation) using the intensities of the pair of images to be registered. The similarity metric is a modification of the cross-correlation met...
coregistration/eolearn/coregistration/coregistration.py
def register(self, src, trg, trg_mask=None, src_mask=None): """ Implementation of pair-wise registration and warping using Enhanced Correlation Coefficient This function estimates an Euclidean transformation (x,y translation + rotation) using the intensities of the pair of images to be register...
def register(self, src, trg, trg_mask=None, src_mask=None): """ Implementation of pair-wise registration and warping using Enhanced Correlation Coefficient This function estimates an Euclidean transformation (x,y translation + rotation) using the intensities of the pair of images to be register...
[ "Implementation", "of", "pair", "-", "wise", "registration", "and", "warping", "using", "Enhanced", "Correlation", "Coefficient" ]
sentinel-hub/eo-learn
python
https://github.com/sentinel-hub/eo-learn/blob/b8c390b9f553c561612fe9eb64e720611633a035/coregistration/eolearn/coregistration/coregistration.py#L263-L290
[ "def", "register", "(", "self", ",", "src", ",", "trg", ",", "trg_mask", "=", "None", ",", "src_mask", "=", "None", ")", ":", "# Parameters of registration", "warp_mode", "=", "cv2", ".", "MOTION_EUCLIDEAN", "# Specify the threshold of the increment", "# in the corr...
b8c390b9f553c561612fe9eb64e720611633a035
train
PointBasedRegistration.register
Implementation of pair-wise registration and warping using point-based matching This function estimates a number of transforms (Euler, PartialAffine and Homography) using point-based matching. Features descriptor are first extracted from the pair of images using either SIFT or SURF descriptors. A ...
coregistration/eolearn/coregistration/coregistration.py
def register(self, src, trg, trg_mask=None, src_mask=None): """ Implementation of pair-wise registration and warping using point-based matching This function estimates a number of transforms (Euler, PartialAffine and Homography) using point-based matching. Features descriptor are first extracte...
def register(self, src, trg, trg_mask=None, src_mask=None): """ Implementation of pair-wise registration and warping using point-based matching This function estimates a number of transforms (Euler, PartialAffine and Homography) using point-based matching. Features descriptor are first extracte...
[ "Implementation", "of", "pair", "-", "wise", "registration", "and", "warping", "using", "point", "-", "based", "matching" ]
sentinel-hub/eo-learn
python
https://github.com/sentinel-hub/eo-learn/blob/b8c390b9f553c561612fe9eb64e720611633a035/coregistration/eolearn/coregistration/coregistration.py#L321-L365
[ "def", "register", "(", "self", ",", "src", ",", "trg", ",", "trg_mask", "=", "None", ",", "src_mask", "=", "None", ")", ":", "# Initialise matrix and failed registrations flag", "warp_matrix", "=", "None", "# Initiate point detector", "ptdt", "=", "cv2", ".", "...
b8c390b9f553c561612fe9eb64e720611633a035
train
PointBasedRegistration.rescale_image
Normalise and scale image in 0-255 range
coregistration/eolearn/coregistration/coregistration.py
def rescale_image(image): """ Normalise and scale image in 0-255 range """ s2_min_value, s2_max_value = 0, 1 out_min_value, out_max_value = 0, 255 # Clamp values in 0-1 range image[image > s2_max_value] = s2_max_value image[image < s2_min_value] = s2_min_value # R...
def rescale_image(image): """ Normalise and scale image in 0-255 range """ s2_min_value, s2_max_value = 0, 1 out_min_value, out_max_value = 0, 255 # Clamp values in 0-1 range image[image > s2_max_value] = s2_max_value image[image < s2_min_value] = s2_min_value # R...
[ "Normalise", "and", "scale", "image", "in", "0", "-", "255", "range" ]
sentinel-hub/eo-learn
python
https://github.com/sentinel-hub/eo-learn/blob/b8c390b9f553c561612fe9eb64e720611633a035/coregistration/eolearn/coregistration/coregistration.py#L368-L377
[ "def", "rescale_image", "(", "image", ")", ":", "s2_min_value", ",", "s2_max_value", "=", "0", ",", "1", "out_min_value", ",", "out_max_value", "=", "0", ",", "255", "# Clamp values in 0-1 range", "image", "[", "image", ">", "s2_max_value", "]", "=", "s2_max_v...
b8c390b9f553c561612fe9eb64e720611633a035
train
Mask2Label.transform
Parameters ---------- X : array-like, shape [n x m] The mask in form of n x m array.
ml_tools/eolearn/ml_tools/truth_transformations.py
def transform(self, X): """ Parameters ---------- X : array-like, shape [n x m] The mask in form of n x m array. """ if self.mode_ == 'target': return np.apply_along_axis(self._target, 1, np.reshape(X, (X.shape[0], X.shape[1] * X.shape[2]))...
def transform(self, X): """ Parameters ---------- X : array-like, shape [n x m] The mask in form of n x m array. """ if self.mode_ == 'target': return np.apply_along_axis(self._target, 1, np.reshape(X, (X.shape[0], X.shape[1] * X.shape[2]))...
[ "Parameters", "----------", "X", ":", "array", "-", "like", "shape", "[", "n", "x", "m", "]", "The", "mask", "in", "form", "of", "n", "x", "m", "array", "." ]
sentinel-hub/eo-learn
python
https://github.com/sentinel-hub/eo-learn/blob/b8c390b9f553c561612fe9eb64e720611633a035/ml_tools/eolearn/ml_tools/truth_transformations.py#L53-L67
[ "def", "transform", "(", "self", ",", "X", ")", ":", "if", "self", ".", "mode_", "==", "'target'", ":", "return", "np", ".", "apply_along_axis", "(", "self", ".", "_target", ",", "1", ",", "np", ".", "reshape", "(", "X", ",", "(", "X", ".", "shap...
b8c390b9f553c561612fe9eb64e720611633a035
train
Mask2TwoClass.transform
Parameters ---------- X : array-like, shape [n x m] The mask in form of n x m array.
ml_tools/eolearn/ml_tools/truth_transformations.py
def transform(self, X): """ Parameters ---------- X : array-like, shape [n x m] The mask in form of n x m array. """ if self.binary_: return (X & self.definition_ > 0).astype(int) return (X == self.definition_).astype(int)
def transform(self, X): """ Parameters ---------- X : array-like, shape [n x m] The mask in form of n x m array. """ if self.binary_: return (X & self.definition_ > 0).astype(int) return (X == self.definition_).astype(int)
[ "Parameters", "----------", "X", ":", "array", "-", "like", "shape", "[", "n", "x", "m", "]", "The", "mask", "in", "form", "of", "n", "x", "m", "array", "." ]
sentinel-hub/eo-learn
python
https://github.com/sentinel-hub/eo-learn/blob/b8c390b9f553c561612fe9eb64e720611633a035/ml_tools/eolearn/ml_tools/truth_transformations.py#L91-L101
[ "def", "transform", "(", "self", ",", "X", ")", ":", "if", "self", ".", "binary_", ":", "return", "(", "X", "&", "self", ".", "definition_", ">", "0", ")", ".", "astype", "(", "int", ")", "return", "(", "X", "==", "self", ".", "definition_", ")",...
b8c390b9f553c561612fe9eb64e720611633a035
train
VectorToRaster._get_submap
Returns a new geopandas dataframe with same structure as original one (columns) except that it contains only polygons that are contained within the given bbox. :param eopatch: input EOPatch :type eopatch: EOPatch :return: New EOPatch :rtype: EOPatch
geometry/eolearn/geometry/utilities.py
def _get_submap(self, eopatch): """ Returns a new geopandas dataframe with same structure as original one (columns) except that it contains only polygons that are contained within the given bbox. :param eopatch: input EOPatch :type eopatch: EOPatch :return: New EOPatch ...
def _get_submap(self, eopatch): """ Returns a new geopandas dataframe with same structure as original one (columns) except that it contains only polygons that are contained within the given bbox. :param eopatch: input EOPatch :type eopatch: EOPatch :return: New EOPatch ...
[ "Returns", "a", "new", "geopandas", "dataframe", "with", "same", "structure", "as", "original", "one", "(", "columns", ")", "except", "that", "it", "contains", "only", "polygons", "that", "are", "contained", "within", "the", "given", "bbox", "." ]
sentinel-hub/eo-learn
python
https://github.com/sentinel-hub/eo-learn/blob/b8c390b9f553c561612fe9eb64e720611633a035/geometry/eolearn/geometry/utilities.py#L88-L103
[ "def", "_get_submap", "(", "self", ",", "eopatch", ")", ":", "bbox_poly", "=", "eopatch", ".", "bbox", ".", "get_geometry", "(", ")", "filtered_data", "=", "self", ".", "vector_data", "[", "self", ".", "vector_data", ".", "geometry", ".", "intersects", "("...
b8c390b9f553c561612fe9eb64e720611633a035
train
VectorToRaster.execute
Execute function which adds new vector layer to the EOPatch :param eopatch: input EOPatch :type eopatch: EOPatch :return: New EOPatch with added vector layer :rtype: EOPatch
geometry/eolearn/geometry/utilities.py
def execute(self, eopatch): """ Execute function which adds new vector layer to the EOPatch :param eopatch: input EOPatch :type eopatch: EOPatch :return: New EOPatch with added vector layer :rtype: EOPatch """ bbox_map = self._get_submap(eopatch) height, ...
def execute(self, eopatch): """ Execute function which adds new vector layer to the EOPatch :param eopatch: input EOPatch :type eopatch: EOPatch :return: New EOPatch with added vector layer :rtype: EOPatch """ bbox_map = self._get_submap(eopatch) height, ...
[ "Execute", "function", "which", "adds", "new", "vector", "layer", "to", "the", "EOPatch" ]
sentinel-hub/eo-learn
python
https://github.com/sentinel-hub/eo-learn/blob/b8c390b9f553c561612fe9eb64e720611633a035/geometry/eolearn/geometry/utilities.py#L115-L138
[ "def", "execute", "(", "self", ",", "eopatch", ")", ":", "bbox_map", "=", "self", ".", "_get_submap", "(", "eopatch", ")", "height", ",", "width", "=", "self", ".", "_get_shape", "(", "eopatch", ")", "data_transform", "=", "rasterio", ".", "transform", "...
b8c390b9f553c561612fe9eb64e720611633a035
train
RasterToVector._vectorize_single_raster
Vectorizes a data slice of a single time component :param raster: Numpy array or shape (height, width, channels) :type raster: numpy.ndarray :param data_transform: Object holding a transform vector (i.e. geographical location vector) of the raster :type data_transform: affine.Affine ...
geometry/eolearn/geometry/utilities.py
def _vectorize_single_raster(self, raster, data_transform, crs, timestamp=None): """ Vectorizes a data slice of a single time component :param raster: Numpy array or shape (height, width, channels) :type raster: numpy.ndarray :param data_transform: Object holding a transform vector (i.e...
def _vectorize_single_raster(self, raster, data_transform, crs, timestamp=None): """ Vectorizes a data slice of a single time component :param raster: Numpy array or shape (height, width, channels) :type raster: numpy.ndarray :param data_transform: Object holding a transform vector (i.e...
[ "Vectorizes", "a", "data", "slice", "of", "a", "single", "time", "component" ]
sentinel-hub/eo-learn
python
https://github.com/sentinel-hub/eo-learn/blob/b8c390b9f553c561612fe9eb64e720611633a035/geometry/eolearn/geometry/utilities.py#L179-L214
[ "def", "_vectorize_single_raster", "(", "self", ",", "raster", ",", "data_transform", ",", "crs", ",", "timestamp", "=", "None", ")", ":", "mask", "=", "None", "if", "self", ".", "values", ":", "mask", "=", "np", ".", "zeros", "(", "raster", ".", "shap...
b8c390b9f553c561612fe9eb64e720611633a035
train
RasterToVector.execute
Execute function which adds new vector layer to the EOPatch :param eopatch: input EOPatch :type eopatch: EOPatch :return: New EOPatch with added vector layer :rtype: EOPatch
geometry/eolearn/geometry/utilities.py
def execute(self, eopatch): """ Execute function which adds new vector layer to the EOPatch :param eopatch: input EOPatch :type eopatch: EOPatch :return: New EOPatch with added vector layer :rtype: EOPatch """ for raster_ft, raster_fn, vector_fn in self.feature_g...
def execute(self, eopatch): """ Execute function which adds new vector layer to the EOPatch :param eopatch: input EOPatch :type eopatch: EOPatch :return: New EOPatch with added vector layer :rtype: EOPatch """ for raster_ft, raster_fn, vector_fn in self.feature_g...
[ "Execute", "function", "which", "adds", "new", "vector", "layer", "to", "the", "EOPatch" ]
sentinel-hub/eo-learn
python
https://github.com/sentinel-hub/eo-learn/blob/b8c390b9f553c561612fe9eb64e720611633a035/geometry/eolearn/geometry/utilities.py#L216-L247
[ "def", "execute", "(", "self", ",", "eopatch", ")", ":", "for", "raster_ft", ",", "raster_fn", ",", "vector_fn", "in", "self", ".", "feature_gen", "(", "eopatch", ")", ":", "vector_ft", "=", "FeatureType", ".", "VECTOR_TIMELESS", "if", "raster_ft", ".", "i...
b8c390b9f553c561612fe9eb64e720611633a035
train
PointSampler.area
Returns the area of the selected polygon if index is provided or of all polygons if it's not.
geometry/eolearn/geometry/sampling.py
def area(self, cc_index=None): """ Returns the area of the selected polygon if index is provided or of all polygons if it's not. """ if cc_index is not None: return self.areas[cc_index] return np.sum(self.areas)
def area(self, cc_index=None): """ Returns the area of the selected polygon if index is provided or of all polygons if it's not. """ if cc_index is not None: return self.areas[cc_index] return np.sum(self.areas)
[ "Returns", "the", "area", "of", "the", "selected", "polygon", "if", "index", "is", "provided", "or", "of", "all", "polygons", "if", "it", "s", "not", "." ]
sentinel-hub/eo-learn
python
https://github.com/sentinel-hub/eo-learn/blob/b8c390b9f553c561612fe9eb64e720611633a035/geometry/eolearn/geometry/sampling.py#L65-L71
[ "def", "area", "(", "self", ",", "cc_index", "=", "None", ")", ":", "if", "cc_index", "is", "not", "None", ":", "return", "self", ".", "areas", "[", "cc_index", "]", "return", "np", ".", "sum", "(", "self", ".", "areas", ")" ]
b8c390b9f553c561612fe9eb64e720611633a035
train
PointSampler.sample
Sample n points from the provided raster mask. The number of points belonging to each class is proportional to the area this class covers in the raster mask, if weighted is set to True. TODO: If polygon has holes the number of sampled points will be less than nsamples :param nsamples: ...
geometry/eolearn/geometry/sampling.py
def sample(self, nsamples=1, weighted=True): """ Sample n points from the provided raster mask. The number of points belonging to each class is proportional to the area this class covers in the raster mask, if weighted is set to True. TODO: If polygon has holes the number of sam...
def sample(self, nsamples=1, weighted=True): """ Sample n points from the provided raster mask. The number of points belonging to each class is proportional to the area this class covers in the raster mask, if weighted is set to True. TODO: If polygon has holes the number of sam...
[ "Sample", "n", "points", "from", "the", "provided", "raster", "mask", ".", "The", "number", "of", "points", "belonging", "to", "each", "class", "is", "proportional", "to", "the", "area", "this", "class", "covers", "in", "the", "raster", "mask", "if", "weig...
sentinel-hub/eo-learn
python
https://github.com/sentinel-hub/eo-learn/blob/b8c390b9f553c561612fe9eb64e720611633a035/geometry/eolearn/geometry/sampling.py#L73-L102
[ "def", "sample", "(", "self", ",", "nsamples", "=", "1", ",", "weighted", "=", "True", ")", ":", "weights", "=", "self", ".", "areas", "/", "np", ".", "sum", "(", "self", ".", "areas", ")", "if", "weighted", "else", "None", "index", "=", "np", "....
b8c390b9f553c561612fe9eb64e720611633a035
train
PointSampler.sample_cc
Returns a random polygon of any class. The probability of each polygon to be sampled is proportional to its area if weighted is True.
geometry/eolearn/geometry/sampling.py
def sample_cc(self, nsamples=1, weighted=True): """ Returns a random polygon of any class. The probability of each polygon to be sampled is proportional to its area if weighted is True. """ weights = self.areas / np.sum(self.areas) if weighted else None for index in np.ra...
def sample_cc(self, nsamples=1, weighted=True): """ Returns a random polygon of any class. The probability of each polygon to be sampled is proportional to its area if weighted is True. """ weights = self.areas / np.sum(self.areas) if weighted else None for index in np.ra...
[ "Returns", "a", "random", "polygon", "of", "any", "class", ".", "The", "probability", "of", "each", "polygon", "to", "be", "sampled", "is", "proportional", "to", "its", "area", "if", "weighted", "is", "True", "." ]
sentinel-hub/eo-learn
python
https://github.com/sentinel-hub/eo-learn/blob/b8c390b9f553c561612fe9eb64e720611633a035/geometry/eolearn/geometry/sampling.py#L104-L111
[ "def", "sample_cc", "(", "self", ",", "nsamples", "=", "1", ",", "weighted", "=", "True", ")", ":", "weights", "=", "self", ".", "areas", "/", "np", ".", "sum", "(", "self", ".", "areas", ")", "if", "weighted", "else", "None", "for", "index", "in",...
b8c390b9f553c561612fe9eb64e720611633a035
train
PointSampler.sample_within_cc
Returns randomly sampled points from a polygon. Complexity of this procedure is (A/a * nsamples) where A=area(bbox(P)) and a=area(P) where P is the polygon of the connected component cc_index
geometry/eolearn/geometry/sampling.py
def sample_within_cc(self, cc_index, nsamples=1): """ Returns randomly sampled points from a polygon. Complexity of this procedure is (A/a * nsamples) where A=area(bbox(P)) and a=area(P) where P is the polygon of the connected component cc_index """ polygon = self.geomet...
def sample_within_cc(self, cc_index, nsamples=1): """ Returns randomly sampled points from a polygon. Complexity of this procedure is (A/a * nsamples) where A=area(bbox(P)) and a=area(P) where P is the polygon of the connected component cc_index """ polygon = self.geomet...
[ "Returns", "randomly", "sampled", "points", "from", "a", "polygon", "." ]
sentinel-hub/eo-learn
python
https://github.com/sentinel-hub/eo-learn/blob/b8c390b9f553c561612fe9eb64e720611633a035/geometry/eolearn/geometry/sampling.py#L113-L126
[ "def", "sample_within_cc", "(", "self", ",", "cc_index", ",", "nsamples", "=", "1", ")", ":", "polygon", "=", "self", ".", "geometries", "[", "cc_index", "]", "[", "'polygon'", "]", "samples", "=", "[", "]", "while", "len", "(", "samples", ")", "<", ...
b8c390b9f553c561612fe9eb64e720611633a035
train
PointSampler.contains
Tests whether point lies within the polygon
geometry/eolearn/geometry/sampling.py
def contains(polygon, point): """ Tests whether point lies within the polygon """ in_hole = functools.reduce( lambda P, Q: P and Q, [interior.covers(point) for interior in polygon.interiors] ) if polygon.interiors else False return polygon.covers(p...
def contains(polygon, point): """ Tests whether point lies within the polygon """ in_hole = functools.reduce( lambda P, Q: P and Q, [interior.covers(point) for interior in polygon.interiors] ) if polygon.interiors else False return polygon.covers(p...
[ "Tests", "whether", "point", "lies", "within", "the", "polygon" ]
sentinel-hub/eo-learn
python
https://github.com/sentinel-hub/eo-learn/blob/b8c390b9f553c561612fe9eb64e720611633a035/geometry/eolearn/geometry/sampling.py#L129-L137
[ "def", "contains", "(", "polygon", ",", "point", ")", ":", "in_hole", "=", "functools", ".", "reduce", "(", "lambda", "P", ",", "Q", ":", "P", "and", "Q", ",", "[", "interior", ".", "covers", "(", "point", ")", "for", "interior", "in", "polygon", "...
b8c390b9f553c561612fe9eb64e720611633a035
train
PointSampler.random_coords
Selects a random point in interior of a rectangle :param bounds: Rectangle coordinates (x_min, y_min, x_max, y_max) :type bounds: tuple(float) :return: Random point from interior of rectangle :rtype: tuple of x and y coordinates
geometry/eolearn/geometry/sampling.py
def random_coords(bounds): """ Selects a random point in interior of a rectangle :param bounds: Rectangle coordinates (x_min, y_min, x_max, y_max) :type bounds: tuple(float) :return: Random point from interior of rectangle :rtype: tuple of x and y coordinates """ ...
def random_coords(bounds): """ Selects a random point in interior of a rectangle :param bounds: Rectangle coordinates (x_min, y_min, x_max, y_max) :type bounds: tuple(float) :return: Random point from interior of rectangle :rtype: tuple of x and y coordinates """ ...
[ "Selects", "a", "random", "point", "in", "interior", "of", "a", "rectangle" ]
sentinel-hub/eo-learn
python
https://github.com/sentinel-hub/eo-learn/blob/b8c390b9f553c561612fe9eb64e720611633a035/geometry/eolearn/geometry/sampling.py#L151-L162
[ "def", "random_coords", "(", "bounds", ")", ":", "x_min", ",", "y_min", ",", "x_max", ",", "y_max", "=", "bounds", "x", "=", "np", ".", "random", ".", "randint", "(", "x_min", ",", "x_max", ")", "y", "=", "np", ".", "random", ".", "randint", "(", ...
b8c390b9f553c561612fe9eb64e720611633a035
train
PointSampler.random_point_triangle
Selects a random point in interior of a triangle
geometry/eolearn/geometry/sampling.py
def random_point_triangle(triangle, use_int_coords=True): """ Selects a random point in interior of a triangle """ xs, ys = triangle.exterior.coords.xy A, B, C = zip(xs[:-1], ys[:-1]) r1, r2 = np.random.rand(), np.random.rand() rx, ry = (1 - sqrt(r1)) * np.asarray...
def random_point_triangle(triangle, use_int_coords=True): """ Selects a random point in interior of a triangle """ xs, ys = triangle.exterior.coords.xy A, B, C = zip(xs[:-1], ys[:-1]) r1, r2 = np.random.rand(), np.random.rand() rx, ry = (1 - sqrt(r1)) * np.asarray...
[ "Selects", "a", "random", "point", "in", "interior", "of", "a", "triangle" ]
sentinel-hub/eo-learn
python
https://github.com/sentinel-hub/eo-learn/blob/b8c390b9f553c561612fe9eb64e720611633a035/geometry/eolearn/geometry/sampling.py#L165-L176
[ "def", "random_point_triangle", "(", "triangle", ",", "use_int_coords", "=", "True", ")", ":", "xs", ",", "ys", "=", "triangle", ".", "exterior", ".", "coords", ".", "xy", "A", ",", "B", ",", "C", "=", "zip", "(", "xs", "[", ":", "-", "1", "]", "...
b8c390b9f553c561612fe9eb64e720611633a035
train
PointRasterSampler._get_unknown_value
Finds the smallest integer value >=0 that is not in `labels` :return: Value that is not in the labels :rtype: int
geometry/eolearn/geometry/sampling.py
def _get_unknown_value(self): """ Finds the smallest integer value >=0 that is not in `labels` :return: Value that is not in the labels :rtype: int """ label_set = set(self.labels) value = 0 while value in label_set: value += 1 return value
def _get_unknown_value(self): """ Finds the smallest integer value >=0 that is not in `labels` :return: Value that is not in the labels :rtype: int """ label_set = set(self.labels) value = 0 while value in label_set: value += 1 return value
[ "Finds", "the", "smallest", "integer", "value", ">", "=", "0", "that", "is", "not", "in", "labels" ]
sentinel-hub/eo-learn
python
https://github.com/sentinel-hub/eo-learn/blob/b8c390b9f553c561612fe9eb64e720611633a035/geometry/eolearn/geometry/sampling.py#L204-L214
[ "def", "_get_unknown_value", "(", "self", ")", ":", "label_set", "=", "set", "(", "self", ".", "labels", ")", "value", "=", "0", "while", "value", "in", "label_set", ":", "value", "+=", "1", "return", "value" ]
b8c390b9f553c561612fe9eb64e720611633a035
train
PointRasterSampler._binary_sample
Sample `nsamples_per_label` points from the binary mask corresponding to `label` Randomly sample `nsamples_per_label` point form the binary mask corresponding to `label`. Sampling with replacement is used if the required `nsamples_per_label` is larger than the available `label_count` :param im...
geometry/eolearn/geometry/sampling.py
def _binary_sample(image, label, n_samples_per_label, label_count): """ Sample `nsamples_per_label` points from the binary mask corresponding to `label` Randomly sample `nsamples_per_label` point form the binary mask corresponding to `label`. Sampling with replacement is used if the required `n...
def _binary_sample(image, label, n_samples_per_label, label_count): """ Sample `nsamples_per_label` points from the binary mask corresponding to `label` Randomly sample `nsamples_per_label` point form the binary mask corresponding to `label`. Sampling with replacement is used if the required `n...
[ "Sample", "nsamples_per_label", "points", "from", "the", "binary", "mask", "corresponding", "to", "label" ]
sentinel-hub/eo-learn
python
https://github.com/sentinel-hub/eo-learn/blob/b8c390b9f553c561612fe9eb64e720611633a035/geometry/eolearn/geometry/sampling.py#L217-L237
[ "def", "_binary_sample", "(", "image", ",", "label", ",", "n_samples_per_label", ",", "label_count", ")", ":", "h_idx", ",", "w_idx", "=", "np", ".", "where", "(", "image", "==", "label", ")", "rand_idx", "=", "np", ".", "random", ".", "choice", "(", "...
b8c390b9f553c561612fe9eb64e720611633a035
train
PointRasterSampler.sample
Sample `nsamples` points form raster :param raster: Input 2D or single-channel 3D label image :type raster: uint8 numpy array :param n_samples: Number of points to sample in total :type n_samples: uint32 :return: List of row indices of samples, list of column indices of samples ...
geometry/eolearn/geometry/sampling.py
def sample(self, raster, n_samples=1000): """ Sample `nsamples` points form raster :param raster: Input 2D or single-channel 3D label image :type raster: uint8 numpy array :param n_samples: Number of points to sample in total :type n_samples: uint32 :return: List of row ...
def sample(self, raster, n_samples=1000): """ Sample `nsamples` points form raster :param raster: Input 2D or single-channel 3D label image :type raster: uint8 numpy array :param n_samples: Number of points to sample in total :type n_samples: uint32 :return: List of row ...
[ "Sample", "nsamples", "points", "form", "raster" ]
sentinel-hub/eo-learn
python
https://github.com/sentinel-hub/eo-learn/blob/b8c390b9f553c561612fe9eb64e720611633a035/geometry/eolearn/geometry/sampling.py#L239-L292
[ "def", "sample", "(", "self", ",", "raster", ",", "n_samples", "=", "1000", ")", ":", "# Check dimensionality and reshape to 2D", "raster", "=", "raster", ".", "copy", "(", ")", "if", "raster", ".", "ndim", "==", "3", "and", "raster", ".", "shape", "[", ...
b8c390b9f553c561612fe9eb64e720611633a035
train
PointSamplingTask.execute
Execute random spatial sampling of time-series stored in the input eopatch :param eopatch: Input eopatch to be sampled :type eopatch: EOPatch :param seed: Setting seed of random sampling. If None no seed will be used. :type seed: int or None :return: An EOPatch with spatially sa...
geometry/eolearn/geometry/sampling.py
def execute(self, eopatch, seed=None): """ Execute random spatial sampling of time-series stored in the input eopatch :param eopatch: Input eopatch to be sampled :type eopatch: EOPatch :param seed: Setting seed of random sampling. If None no seed will be used. :type seed: int or...
def execute(self, eopatch, seed=None): """ Execute random spatial sampling of time-series stored in the input eopatch :param eopatch: Input eopatch to be sampled :type eopatch: EOPatch :param seed: Setting seed of random sampling. If None no seed will be used. :type seed: int or...
[ "Execute", "random", "spatial", "sampling", "of", "time", "-", "series", "stored", "in", "the", "input", "eopatch" ]
sentinel-hub/eo-learn
python
https://github.com/sentinel-hub/eo-learn/blob/b8c390b9f553c561612fe9eb64e720611633a035/geometry/eolearn/geometry/sampling.py#L343-L381
[ "def", "execute", "(", "self", ",", "eopatch", ",", "seed", "=", "None", ")", ":", "np", ".", "random", ".", "seed", "(", "seed", ")", "# Retrieve data and raster label image from eopatch", "f_type", ",", "f_name", "=", "next", "(", "self", ".", "ref_mask_fe...
b8c390b9f553c561612fe9eb64e720611633a035
train
SaveToDisk.execute
Saves the EOPatch to disk: `folder/eopatch_folder`. :param eopatch: EOPatch which will be saved :type eopatch: EOPatch :param eopatch_folder: name of EOPatch folder containing data :type eopatch_folder: str :return: The same EOPatch :rtype: EOPatch
core/eolearn/core/core_tasks.py
def execute(self, eopatch, *, eopatch_folder): """Saves the EOPatch to disk: `folder/eopatch_folder`. :param eopatch: EOPatch which will be saved :type eopatch: EOPatch :param eopatch_folder: name of EOPatch folder containing data :type eopatch_folder: str :return: The s...
def execute(self, eopatch, *, eopatch_folder): """Saves the EOPatch to disk: `folder/eopatch_folder`. :param eopatch: EOPatch which will be saved :type eopatch: EOPatch :param eopatch_folder: name of EOPatch folder containing data :type eopatch_folder: str :return: The s...
[ "Saves", "the", "EOPatch", "to", "disk", ":", "folder", "/", "eopatch_folder", "." ]
sentinel-hub/eo-learn
python
https://github.com/sentinel-hub/eo-learn/blob/b8c390b9f553c561612fe9eb64e720611633a035/core/eolearn/core/core_tasks.py#L57-L68
[ "def", "execute", "(", "self", ",", "eopatch", ",", "*", ",", "eopatch_folder", ")", ":", "eopatch", ".", "save", "(", "os", ".", "path", ".", "join", "(", "self", ".", "folder", ",", "eopatch_folder", ")", ",", "*", "self", ".", "args", ",", "*", ...
b8c390b9f553c561612fe9eb64e720611633a035
train
LoadFromDisk.execute
Loads the EOPatch from disk: `folder/eopatch_folder`. :param eopatch_folder: name of EOPatch folder containing data :type eopatch_folder: str :return: EOPatch loaded from disk :rtype: EOPatch
core/eolearn/core/core_tasks.py
def execute(self, *, eopatch_folder): """Loads the EOPatch from disk: `folder/eopatch_folder`. :param eopatch_folder: name of EOPatch folder containing data :type eopatch_folder: str :return: EOPatch loaded from disk :rtype: EOPatch """ eopatch = EOPatch.load(os....
def execute(self, *, eopatch_folder): """Loads the EOPatch from disk: `folder/eopatch_folder`. :param eopatch_folder: name of EOPatch folder containing data :type eopatch_folder: str :return: EOPatch loaded from disk :rtype: EOPatch """ eopatch = EOPatch.load(os....
[ "Loads", "the", "EOPatch", "from", "disk", ":", "folder", "/", "eopatch_folder", "." ]
sentinel-hub/eo-learn
python
https://github.com/sentinel-hub/eo-learn/blob/b8c390b9f553c561612fe9eb64e720611633a035/core/eolearn/core/core_tasks.py#L88-L97
[ "def", "execute", "(", "self", ",", "*", ",", "eopatch_folder", ")", ":", "eopatch", "=", "EOPatch", ".", "load", "(", "os", ".", "path", ".", "join", "(", "self", ".", "folder", ",", "eopatch_folder", ")", ",", "*", "self", ".", "args", ",", "*", ...
b8c390b9f553c561612fe9eb64e720611633a035
train
AddFeature.execute
Returns the EOPatch with added features. :param eopatch: input EOPatch :type eopatch: EOPatch :param data: data to be added to the feature :type data: object :return: input EOPatch with the specified feature :rtype: EOPatch
core/eolearn/core/core_tasks.py
def execute(self, eopatch, data): """Returns the EOPatch with added features. :param eopatch: input EOPatch :type eopatch: EOPatch :param data: data to be added to the feature :type data: object :return: input EOPatch with the specified feature :rtype: EOPatch ...
def execute(self, eopatch, data): """Returns the EOPatch with added features. :param eopatch: input EOPatch :type eopatch: EOPatch :param data: data to be added to the feature :type data: object :return: input EOPatch with the specified feature :rtype: EOPatch ...
[ "Returns", "the", "EOPatch", "with", "added", "features", "." ]
sentinel-hub/eo-learn
python
https://github.com/sentinel-hub/eo-learn/blob/b8c390b9f553c561612fe9eb64e720611633a035/core/eolearn/core/core_tasks.py#L109-L124
[ "def", "execute", "(", "self", ",", "eopatch", ",", "data", ")", ":", "if", "self", ".", "feature_name", "is", "None", ":", "eopatch", "[", "self", ".", "feature_type", "]", "=", "data", "else", ":", "eopatch", "[", "self", ".", "feature_type", "]", ...
b8c390b9f553c561612fe9eb64e720611633a035
train
RemoveFeature.execute
Returns the EOPatch with removed features. :param eopatch: input EOPatch :type eopatch: EOPatch :return: input EOPatch without the specified feature :rtype: EOPatch
core/eolearn/core/core_tasks.py
def execute(self, eopatch): """Returns the EOPatch with removed features. :param eopatch: input EOPatch :type eopatch: EOPatch :return: input EOPatch without the specified feature :rtype: EOPatch """ for feature_type, feature_name in self.feature_gen(eopatch): ...
def execute(self, eopatch): """Returns the EOPatch with removed features. :param eopatch: input EOPatch :type eopatch: EOPatch :return: input EOPatch without the specified feature :rtype: EOPatch """ for feature_type, feature_name in self.feature_gen(eopatch): ...
[ "Returns", "the", "EOPatch", "with", "removed", "features", "." ]
sentinel-hub/eo-learn
python
https://github.com/sentinel-hub/eo-learn/blob/b8c390b9f553c561612fe9eb64e720611633a035/core/eolearn/core/core_tasks.py#L136-L150
[ "def", "execute", "(", "self", ",", "eopatch", ")", ":", "for", "feature_type", ",", "feature_name", "in", "self", ".", "feature_gen", "(", "eopatch", ")", ":", "if", "feature_name", "is", "...", ":", "eopatch", ".", "reset_feature_type", "(", "feature_type"...
b8c390b9f553c561612fe9eb64e720611633a035
train
RenameFeature.execute
Returns the EOPatch with renamed features. :param eopatch: input EOPatch :type eopatch: EOPatch :return: input EOPatch with the renamed features :rtype: EOPatch
core/eolearn/core/core_tasks.py
def execute(self, eopatch): """Returns the EOPatch with renamed features. :param eopatch: input EOPatch :type eopatch: EOPatch :return: input EOPatch with the renamed features :rtype: EOPatch """ for feature_type, feature_name, new_feature_name in self.feature_ge...
def execute(self, eopatch): """Returns the EOPatch with renamed features. :param eopatch: input EOPatch :type eopatch: EOPatch :return: input EOPatch with the renamed features :rtype: EOPatch """ for feature_type, feature_name, new_feature_name in self.feature_ge...
[ "Returns", "the", "EOPatch", "with", "renamed", "features", "." ]
sentinel-hub/eo-learn
python
https://github.com/sentinel-hub/eo-learn/blob/b8c390b9f553c561612fe9eb64e720611633a035/core/eolearn/core/core_tasks.py#L162-L174
[ "def", "execute", "(", "self", ",", "eopatch", ")", ":", "for", "feature_type", ",", "feature_name", ",", "new_feature_name", "in", "self", ".", "feature_gen", "(", "eopatch", ")", ":", "eopatch", "[", "feature_type", "]", "[", "new_feature_name", "]", "=", ...
b8c390b9f553c561612fe9eb64e720611633a035
train
BaseCompositing._numpy_index_by_percentile
Calculate percentile of numpy stack and return the index of the chosen pixel. numpy percentile function is used with one of the following interpolations {'linear', 'lower', 'higher', 'midpoint', 'nearest'}
features/eolearn/features/radiometric_normalization.py
def _numpy_index_by_percentile(self, data, percentile): """ Calculate percentile of numpy stack and return the index of the chosen pixel. numpy percentile function is used with one of the following interpolations {'linear', 'lower', 'higher', 'midpoint', 'nearest'} """ d...
def _numpy_index_by_percentile(self, data, percentile): """ Calculate percentile of numpy stack and return the index of the chosen pixel. numpy percentile function is used with one of the following interpolations {'linear', 'lower', 'higher', 'midpoint', 'nearest'} """ d...
[ "Calculate", "percentile", "of", "numpy", "stack", "and", "return", "the", "index", "of", "the", "chosen", "pixel", "." ]
sentinel-hub/eo-learn
python
https://github.com/sentinel-hub/eo-learn/blob/b8c390b9f553c561612fe9eb64e720611633a035/features/eolearn/features/radiometric_normalization.py#L87-L102
[ "def", "_numpy_index_by_percentile", "(", "self", ",", "data", ",", "percentile", ")", ":", "data_perc_low", "=", "np", ".", "nanpercentile", "(", "data", ",", "percentile", ",", "axis", "=", "0", ",", "interpolation", "=", "self", ".", "interpolation", ")",...
b8c390b9f553c561612fe9eb64e720611633a035
train
BaseCompositing._geoville_index_by_percentile
Calculate percentile of numpy stack and return the index of the chosen pixel.
features/eolearn/features/radiometric_normalization.py
def _geoville_index_by_percentile(self, data, percentile): """ Calculate percentile of numpy stack and return the index of the chosen pixel. """ # no_obs = bn.allnan(arr_tmp["data"], axis=0) data_tmp = np.array(data, copy=True) valid_obs = np.sum(np.isfinite(data_tmp), axis=0) # ...
def _geoville_index_by_percentile(self, data, percentile): """ Calculate percentile of numpy stack and return the index of the chosen pixel. """ # no_obs = bn.allnan(arr_tmp["data"], axis=0) data_tmp = np.array(data, copy=True) valid_obs = np.sum(np.isfinite(data_tmp), axis=0) # ...
[ "Calculate", "percentile", "of", "numpy", "stack", "and", "return", "the", "index", "of", "the", "chosen", "pixel", "." ]
sentinel-hub/eo-learn
python
https://github.com/sentinel-hub/eo-learn/blob/b8c390b9f553c561612fe9eb64e720611633a035/features/eolearn/features/radiometric_normalization.py#L104-L124
[ "def", "_geoville_index_by_percentile", "(", "self", ",", "data", ",", "percentile", ")", ":", "# no_obs = bn.allnan(arr_tmp[\"data\"], axis=0)", "data_tmp", "=", "np", ".", "array", "(", "data", ",", "copy", "=", "True", ")", "valid_obs", "=", "np", ".", "sum",...
b8c390b9f553c561612fe9eb64e720611633a035
train
BaseCompositing._get_indices
Compute indices along temporal dimension corresponding to the sought percentile :param data: Input 3D array holding the reference band :type data: numpy array :return: 2D array holding the temporal index corresponding to percentile
features/eolearn/features/radiometric_normalization.py
def _get_indices(self, data): """ Compute indices along temporal dimension corresponding to the sought percentile :param data: Input 3D array holding the reference band :type data: numpy array :return: 2D array holding the temporal index corresponding to percentile "...
def _get_indices(self, data): """ Compute indices along temporal dimension corresponding to the sought percentile :param data: Input 3D array holding the reference band :type data: numpy array :return: 2D array holding the temporal index corresponding to percentile "...
[ "Compute", "indices", "along", "temporal", "dimension", "corresponding", "to", "the", "sought", "percentile" ]
sentinel-hub/eo-learn
python
https://github.com/sentinel-hub/eo-learn/blob/b8c390b9f553c561612fe9eb64e720611633a035/features/eolearn/features/radiometric_normalization.py#L135-L143
[ "def", "_get_indices", "(", "self", ",", "data", ")", ":", "indices", "=", "self", ".", "_index_by_percentile", "(", "data", ",", "self", ".", "percentile", ")", "return", "indices" ]
b8c390b9f553c561612fe9eb64e720611633a035
train
BaseCompositing.execute
Compute composite array merging temporal frames according to the compositing method :param eopatch: eopatch holding time-series :return: eopatch with composite image of time-series
features/eolearn/features/radiometric_normalization.py
def execute(self, eopatch): """ Compute composite array merging temporal frames according to the compositing method :param eopatch: eopatch holding time-series :return: eopatch with composite image of time-series """ feature_type, feature_name = next(self.feature(eopatch...
def execute(self, eopatch): """ Compute composite array merging temporal frames according to the compositing method :param eopatch: eopatch holding time-series :return: eopatch with composite image of time-series """ feature_type, feature_name = next(self.feature(eopatch...
[ "Compute", "composite", "array", "merging", "temporal", "frames", "according", "to", "the", "compositing", "method" ]
sentinel-hub/eo-learn
python
https://github.com/sentinel-hub/eo-learn/blob/b8c390b9f553c561612fe9eb64e720611633a035/features/eolearn/features/radiometric_normalization.py#L145-L168
[ "def", "execute", "(", "self", ",", "eopatch", ")", ":", "feature_type", ",", "feature_name", "=", "next", "(", "self", ".", "feature", "(", "eopatch", ")", ")", "data", "=", "eopatch", "[", "feature_type", "]", "[", "feature_name", "]", ".", "copy", "...
b8c390b9f553c561612fe9eb64e720611633a035
train
MaxNDVICompositing._get_reference_band
Extract the NDVI band from time-series :param data: 4D array from which to compute the NDVI reference band :type data: numpy array :return: 3D array containing the NDVI reference band
features/eolearn/features/radiometric_normalization.py
def _get_reference_band(self, data): """ Extract the NDVI band from time-series :param data: 4D array from which to compute the NDVI reference band :type data: numpy array :return: 3D array containing the NDVI reference band """ nir = data[..., self.nir_idx].astype("floa...
def _get_reference_band(self, data): """ Extract the NDVI band from time-series :param data: 4D array from which to compute the NDVI reference band :type data: numpy array :return: 3D array containing the NDVI reference band """ nir = data[..., self.nir_idx].astype("floa...
[ "Extract", "the", "NDVI", "band", "from", "time", "-", "series" ]
sentinel-hub/eo-learn
python
https://github.com/sentinel-hub/eo-learn/blob/b8c390b9f553c561612fe9eb64e720611633a035/features/eolearn/features/radiometric_normalization.py#L243-L252
[ "def", "_get_reference_band", "(", "self", ",", "data", ")", ":", "nir", "=", "data", "[", "...", ",", "self", ".", "nir_idx", "]", ".", "astype", "(", "\"float32\"", ")", "red", "=", "data", "[", "...", ",", "self", ".", "red_idx", "]", ".", "asty...
b8c390b9f553c561612fe9eb64e720611633a035
train
MaxNDWICompositing._get_reference_band
Extract the NDWI band from time-series :param data: 4D array from which to compute the NDWI reference band :type data: numpy array :return: 3D array containing the NDWI reference band
features/eolearn/features/radiometric_normalization.py
def _get_reference_band(self, data): """ Extract the NDWI band from time-series :param data: 4D array from which to compute the NDWI reference band :type data: numpy array :return: 3D array containing the NDWI reference band """ nir = data[..., self.nir_idx].astype("floa...
def _get_reference_band(self, data): """ Extract the NDWI band from time-series :param data: 4D array from which to compute the NDWI reference band :type data: numpy array :return: 3D array containing the NDWI reference band """ nir = data[..., self.nir_idx].astype("floa...
[ "Extract", "the", "NDWI", "band", "from", "time", "-", "series" ]
sentinel-hub/eo-learn
python
https://github.com/sentinel-hub/eo-learn/blob/b8c390b9f553c561612fe9eb64e720611633a035/features/eolearn/features/radiometric_normalization.py#L279-L288
[ "def", "_get_reference_band", "(", "self", ",", "data", ")", ":", "nir", "=", "data", "[", "...", ",", "self", ".", "nir_idx", "]", ".", "astype", "(", "\"float32\"", ")", "swir1", "=", "data", "[", "...", ",", "self", ".", "swir1_idx", "]", ".", "...
b8c390b9f553c561612fe9eb64e720611633a035
train
MaxRatioCompositing._get_reference_band
Extract the max-ratio band from time-series The max-ratio is defined as max(NIR,SWIR1)/BLUE :param data: 4D array from which to compute the max-ratio reference band :type data: numpy array :return: 3D array containing the max-ratio reference band
features/eolearn/features/radiometric_normalization.py
def _get_reference_band(self, data): """ Extract the max-ratio band from time-series The max-ratio is defined as max(NIR,SWIR1)/BLUE :param data: 4D array from which to compute the max-ratio reference band :type data: numpy array :return: 3D array containing the...
def _get_reference_band(self, data): """ Extract the max-ratio band from time-series The max-ratio is defined as max(NIR,SWIR1)/BLUE :param data: 4D array from which to compute the max-ratio reference band :type data: numpy array :return: 3D array containing the...
[ "Extract", "the", "max", "-", "ratio", "band", "from", "time", "-", "series" ]
sentinel-hub/eo-learn
python
https://github.com/sentinel-hub/eo-learn/blob/b8c390b9f553c561612fe9eb64e720611633a035/features/eolearn/features/radiometric_normalization.py#L311-L323
[ "def", "_get_reference_band", "(", "self", ",", "data", ")", ":", "blue", "=", "data", "[", "...", ",", "self", ".", "blue_idx", "]", ".", "astype", "(", "\"float32\"", ")", "nir", "=", "data", "[", "...", ",", "self", ".", "nir_idx", "]", ".", "as...
b8c390b9f553c561612fe9eb64e720611633a035
train
HistogramMatching.execute
Perform histogram matching of the time-series with respect to a reference scene :param eopatch: eopatch holding the time-series and reference data :type eopatch: EOPatch :return: The same eopatch instance with the normalised time-series
features/eolearn/features/radiometric_normalization.py
def execute(self, eopatch): """ Perform histogram matching of the time-series with respect to a reference scene :param eopatch: eopatch holding the time-series and reference data :type eopatch: EOPatch :return: The same eopatch instance with the normalised time-series ...
def execute(self, eopatch): """ Perform histogram matching of the time-series with respect to a reference scene :param eopatch: eopatch holding the time-series and reference data :type eopatch: EOPatch :return: The same eopatch instance with the normalised time-series ...
[ "Perform", "histogram", "matching", "of", "the", "time", "-", "series", "with", "respect", "to", "a", "reference", "scene" ]
sentinel-hub/eo-learn
python
https://github.com/sentinel-hub/eo-learn/blob/b8c390b9f553c561612fe9eb64e720611633a035/features/eolearn/features/radiometric_normalization.py#L346-L375
[ "def", "execute", "(", "self", ",", "eopatch", ")", ":", "feature_type", ",", "feature_name", ",", "new_feature_name", "=", "next", "(", "self", ".", "feature", "(", "eopatch", ")", ")", "reference_type", ",", "reference_name", "=", "next", "(", "self", "....
b8c390b9f553c561612fe9eb64e720611633a035
train
_FeatureDict._parse_feature_value
Checks if value fits the feature type. If not it tries to fix it or raise an error :raises: ValueError
core/eolearn/core/eodata.py
def _parse_feature_value(self, value): """ Checks if value fits the feature type. If not it tries to fix it or raise an error :raises: ValueError """ if isinstance(value, _FileLoader): return value if not hasattr(self, 'ndim'): # Because of serialization/dese...
def _parse_feature_value(self, value): """ Checks if value fits the feature type. If not it tries to fix it or raise an error :raises: ValueError """ if isinstance(value, _FileLoader): return value if not hasattr(self, 'ndim'): # Because of serialization/dese...
[ "Checks", "if", "value", "fits", "the", "feature", "type", ".", "If", "not", "it", "tries", "to", "fix", "it", "or", "raise", "an", "error", ":", "raises", ":", "ValueError" ]
sentinel-hub/eo-learn
python
https://github.com/sentinel-hub/eo-learn/blob/b8c390b9f553c561612fe9eb64e720611633a035/core/eolearn/core/eodata.py#L804-L854
[ "def", "_parse_feature_value", "(", "self", ",", "value", ")", ":", "if", "isinstance", "(", "value", ",", "_FileLoader", ")", ":", "return", "value", "if", "not", "hasattr", "(", "self", ",", "'ndim'", ")", ":", "# Because of serialization/deserialization durin...
b8c390b9f553c561612fe9eb64e720611633a035
train
_FileLoader._correctly_load_bbox
Helper method for loading old version of pickled BBox object :param bbox: BBox object which was incorrectly loaded with pickle :type bbox: sentinelhub.BBox :param path: Path to file where BBox object is stored :type path: str :param is_zipped: `True` if file is zipped and ...
core/eolearn/core/eodata.py
def _correctly_load_bbox(bbox, path, is_zipped=False): """ Helper method for loading old version of pickled BBox object :param bbox: BBox object which was incorrectly loaded with pickle :type bbox: sentinelhub.BBox :param path: Path to file where BBox object is stored :typ...
def _correctly_load_bbox(bbox, path, is_zipped=False): """ Helper method for loading old version of pickled BBox object :param bbox: BBox object which was incorrectly loaded with pickle :type bbox: sentinelhub.BBox :param path: Path to file where BBox object is stored :typ...
[ "Helper", "method", "for", "loading", "old", "version", "of", "pickled", "BBox", "object", ":", "param", "bbox", ":", "BBox", "object", "which", "was", "incorrectly", "loaded", "with", "pickle", ":", "type", "bbox", ":", "sentinelhub", ".", "BBox", ":", "p...
sentinel-hub/eo-learn
python
https://github.com/sentinel-hub/eo-learn/blob/b8c390b9f553c561612fe9eb64e720611633a035/core/eolearn/core/eodata.py#L887-L912
[ "def", "_correctly_load_bbox", "(", "bbox", ",", "path", ",", "is_zipped", "=", "False", ")", ":", "warnings", ".", "warn", "(", "\"Bounding box of your EOPatch is saved in old format which in the future won't be supported \"", "\"anymore. Please save bounding box again, you can ov...
b8c390b9f553c561612fe9eb64e720611633a035
train
_FileLoader.load
Method which loads data from the file
core/eolearn/core/eodata.py
def load(self): """ Method which loads data from the file """ # pylint: disable=too-many-return-statements if not os.path.isdir(self.patch_path): raise OSError('EOPatch does not exist in path {} anymore'.format(self.patch_path)) path = self.get_file_path() ...
def load(self): """ Method which loads data from the file """ # pylint: disable=too-many-return-statements if not os.path.isdir(self.patch_path): raise OSError('EOPatch does not exist in path {} anymore'.format(self.patch_path)) path = self.get_file_path() ...
[ "Method", "which", "loads", "data", "from", "the", "file" ]
sentinel-hub/eo-learn
python
https://github.com/sentinel-hub/eo-learn/blob/b8c390b9f553c561612fe9eb64e720611633a035/core/eolearn/core/eodata.py#L914-L951
[ "def", "load", "(", "self", ")", ":", "# pylint: disable=too-many-return-statements\r", "if", "not", "os", ".", "path", ".", "isdir", "(", "self", ".", "patch_path", ")", ":", "raise", "OSError", "(", "'EOPatch does not exist in path {} anymore'", ".", "format", "...
b8c390b9f553c561612fe9eb64e720611633a035
train
_FileSaver.get_file_path
Creates a filename with file path
core/eolearn/core/eodata.py
def get_file_path(self, path): """ Creates a filename with file path """ feature_filename = self._get_filename_path(path) feature_filename += self.file_format.extension() if self.compress_level: feature_filename += FileFormat.GZIP.extension() return...
def get_file_path(self, path): """ Creates a filename with file path """ feature_filename = self._get_filename_path(path) feature_filename += self.file_format.extension() if self.compress_level: feature_filename += FileFormat.GZIP.extension() return...
[ "Creates", "a", "filename", "with", "file", "path" ]
sentinel-hub/eo-learn
python
https://github.com/sentinel-hub/eo-learn/blob/b8c390b9f553c561612fe9eb64e720611633a035/core/eolearn/core/eodata.py#L966-L975
[ "def", "get_file_path", "(", "self", ",", "path", ")", ":", "feature_filename", "=", "self", ".", "_get_filename_path", "(", "path", ")", "feature_filename", "+=", "self", ".", "file_format", ".", "extension", "(", ")", "if", "self", ".", "compress_level", "...
b8c390b9f553c561612fe9eb64e720611633a035
train
_FileSaver._get_filename_path
Helper function for creating filename without file extension
core/eolearn/core/eodata.py
def _get_filename_path(self, path): """ Helper function for creating filename without file extension """ feature_filename = os.path.join(path, self.feature_type.value) if self.feature_name is not None: feature_filename = os.path.join(feature_filename, self.feature_name...
def _get_filename_path(self, path): """ Helper function for creating filename without file extension """ feature_filename = os.path.join(path, self.feature_type.value) if self.feature_name is not None: feature_filename = os.path.join(feature_filename, self.feature_name...
[ "Helper", "function", "for", "creating", "filename", "without", "file", "extension" ]
sentinel-hub/eo-learn
python
https://github.com/sentinel-hub/eo-learn/blob/b8c390b9f553c561612fe9eb64e720611633a035/core/eolearn/core/eodata.py#L977-L985
[ "def", "_get_filename_path", "(", "self", ",", "path", ")", ":", "feature_filename", "=", "os", ".", "path", ".", "join", "(", "path", ",", "self", ".", "feature_type", ".", "value", ")", "if", "self", ".", "feature_name", "is", "not", "None", ":", "fe...
b8c390b9f553c561612fe9eb64e720611633a035
train
_FileSaver.save
Method which does the saving :param eopatch: EOPatch containing the data which will be saved :type eopatch: EOPatch :param use_tmp: If `True` data will be saved to temporary file, otherwise it will be saved to intended (i.e. final) location :type use_tmp: bool
core/eolearn/core/eodata.py
def save(self, eopatch, use_tmp=True): """ Method which does the saving :param eopatch: EOPatch containing the data which will be saved :type eopatch: EOPatch :param use_tmp: If `True` data will be saved to temporary file, otherwise it will be saved to intended (i.e. final...
def save(self, eopatch, use_tmp=True): """ Method which does the saving :param eopatch: EOPatch containing the data which will be saved :type eopatch: EOPatch :param use_tmp: If `True` data will be saved to temporary file, otherwise it will be saved to intended (i.e. final...
[ "Method", "which", "does", "the", "saving", ":", "param", "eopatch", ":", "EOPatch", "containing", "the", "data", "which", "will", "be", "saved", ":", "type", "eopatch", ":", "EOPatch", ":", "param", "use_tmp", ":", "If", "True", "data", "will", "be", "s...
sentinel-hub/eo-learn
python
https://github.com/sentinel-hub/eo-learn/blob/b8c390b9f553c561612fe9eb64e720611633a035/core/eolearn/core/eodata.py#L987-L1025
[ "def", "save", "(", "self", ",", "eopatch", ",", "use_tmp", "=", "True", ")", ":", "filename", "=", "self", ".", "tmp_filename", "if", "use_tmp", "else", "self", ".", "final_filename", "if", "self", ".", "feature_name", "is", "None", ":", "data", "=", ...
b8c390b9f553c561612fe9eb64e720611633a035
train
InterpolationTask._mask_feature_data
Masks values of data feature with a given mask of given mask type. The masking is done by assigning `numpy.nan` value. :param feature_data: Data array which will be masked :type feature_data: numpy.ndarray :param mask: Mask array :type mask: numpy.ndarray :param mask_typ...
features/eolearn/features/interpolation.py
def _mask_feature_data(feature_data, mask, mask_type): """ Masks values of data feature with a given mask of given mask type. The masking is done by assigning `numpy.nan` value. :param feature_data: Data array which will be masked :type feature_data: numpy.ndarray :param mask: M...
def _mask_feature_data(feature_data, mask, mask_type): """ Masks values of data feature with a given mask of given mask type. The masking is done by assigning `numpy.nan` value. :param feature_data: Data array which will be masked :type feature_data: numpy.ndarray :param mask: M...
[ "Masks", "values", "of", "data", "feature", "with", "a", "given", "mask", "of", "given", "mask", "type", ".", "The", "masking", "is", "done", "by", "assigning", "numpy", ".", "nan", "value", "." ]
sentinel-hub/eo-learn
python
https://github.com/sentinel-hub/eo-learn/blob/b8c390b9f553c561612fe9eb64e720611633a035/features/eolearn/features/interpolation.py#L90-L127
[ "def", "_mask_feature_data", "(", "feature_data", ",", "mask", ",", "mask_type", ")", ":", "if", "mask_type", ".", "is_spatial", "(", ")", "and", "feature_data", ".", "shape", "[", "1", ":", "3", "]", "!=", "mask", ".", "shape", "[", "-", "3", ":", "...
b8c390b9f553c561612fe9eb64e720611633a035
train
InterpolationTask._get_start_end_nans
Find NaN values in data that either start or end the time-series Function to return a binary array of same size as data where `True` values correspond to NaN values present at beginning or end of time-series. NaNs internal to the time-series are not included in the binary mask. :param data: Ar...
features/eolearn/features/interpolation.py
def _get_start_end_nans(data): """ Find NaN values in data that either start or end the time-series Function to return a binary array of same size as data where `True` values correspond to NaN values present at beginning or end of time-series. NaNs internal to the time-series are not included i...
def _get_start_end_nans(data): """ Find NaN values in data that either start or end the time-series Function to return a binary array of same size as data where `True` values correspond to NaN values present at beginning or end of time-series. NaNs internal to the time-series are not included i...
[ "Find", "NaN", "values", "in", "data", "that", "either", "start", "or", "end", "the", "time", "-", "series" ]
sentinel-hub/eo-learn
python
https://github.com/sentinel-hub/eo-learn/blob/b8c390b9f553c561612fe9eb64e720611633a035/features/eolearn/features/interpolation.py#L130-L150
[ "def", "_get_start_end_nans", "(", "data", ")", ":", "# find NaNs that start a time-series", "start_nan", "=", "np", ".", "isnan", "(", "data", ")", "for", "idx", ",", "row", "in", "enumerate", "(", "start_nan", "[", ":", "-", "1", "]", ")", ":", "start_na...
b8c390b9f553c561612fe9eb64e720611633a035
train
InterpolationTask._get_unique_times
Replace duplicate acquisitions which have same values on the chosen time scale with their average. The average is calculated with numpy.nanmean, meaning that NaN values are ignored when calculating the average. :param data: Array in a shape of t x nobs, where nobs = h x w x n :type data: numpy....
features/eolearn/features/interpolation.py
def _get_unique_times(data, times): """ Replace duplicate acquisitions which have same values on the chosen time scale with their average. The average is calculated with numpy.nanmean, meaning that NaN values are ignored when calculating the average. :param data: Array in a shape of t x nobs, w...
def _get_unique_times(data, times): """ Replace duplicate acquisitions which have same values on the chosen time scale with their average. The average is calculated with numpy.nanmean, meaning that NaN values are ignored when calculating the average. :param data: Array in a shape of t x nobs, w...
[ "Replace", "duplicate", "acquisitions", "which", "have", "same", "values", "on", "the", "chosen", "time", "scale", "with", "their", "average", ".", "The", "average", "is", "calculated", "with", "numpy", ".", "nanmean", "meaning", "that", "NaN", "values", "are"...
sentinel-hub/eo-learn
python
https://github.com/sentinel-hub/eo-learn/blob/b8c390b9f553c561612fe9eb64e720611633a035/features/eolearn/features/interpolation.py#L153-L179
[ "def", "_get_unique_times", "(", "data", ",", "times", ")", ":", "seen", "=", "set", "(", ")", "duplicated_indices", "=", "np", ".", "array", "(", "[", "idx", "for", "idx", ",", "item", "in", "enumerate", "(", "times", ")", "if", "item", "in", "seen"...
b8c390b9f553c561612fe9eb64e720611633a035
train
InterpolationTask._copy_old_features
Copy features from old EOPatch :param new_eopatch: New EOPatch container where the old features will be copied to :type new_eopatch: EOPatch :param old_eopatch: Old EOPatch container where the old features are located :type old_eopatch: EOPatch :param copy_features: List of tupl...
features/eolearn/features/interpolation.py
def _copy_old_features(new_eopatch, old_eopatch, copy_features): """ Copy features from old EOPatch :param new_eopatch: New EOPatch container where the old features will be copied to :type new_eopatch: EOPatch :param old_eopatch: Old EOPatch container where the old features are located ...
def _copy_old_features(new_eopatch, old_eopatch, copy_features): """ Copy features from old EOPatch :param new_eopatch: New EOPatch container where the old features will be copied to :type new_eopatch: EOPatch :param old_eopatch: Old EOPatch container where the old features are located ...
[ "Copy", "features", "from", "old", "EOPatch" ]
sentinel-hub/eo-learn
python
https://github.com/sentinel-hub/eo-learn/blob/b8c390b9f553c561612fe9eb64e720611633a035/features/eolearn/features/interpolation.py#L182-L209
[ "def", "_copy_old_features", "(", "new_eopatch", ",", "old_eopatch", ",", "copy_features", ")", ":", "if", "copy_features", ":", "existing_features", "=", "set", "(", "new_eopatch", ".", "get_feature_list", "(", ")", ")", "for", "copy_feature_type", ",", "copy_fea...
b8c390b9f553c561612fe9eb64e720611633a035
train
InterpolationTask.interpolate_data
Interpolates data feature :param data: Array in a shape of t x nobs, where nobs = h x w x n :type data: numpy.ndarray :param times: Array of reference times relative to the first timestamp :type times: numpy.array :param resampled_times: Array of reference times relative to the ...
features/eolearn/features/interpolation.py
def interpolate_data(self, data, times, resampled_times): """ Interpolates data feature :param data: Array in a shape of t x nobs, where nobs = h x w x n :type data: numpy.ndarray :param times: Array of reference times relative to the first timestamp :type times: numpy.array ...
def interpolate_data(self, data, times, resampled_times): """ Interpolates data feature :param data: Array in a shape of t x nobs, where nobs = h x w x n :type data: numpy.ndarray :param times: Array of reference times relative to the first timestamp :type times: numpy.array ...
[ "Interpolates", "data", "feature" ]
sentinel-hub/eo-learn
python
https://github.com/sentinel-hub/eo-learn/blob/b8c390b9f553c561612fe9eb64e720611633a035/features/eolearn/features/interpolation.py#L211-L284
[ "def", "interpolate_data", "(", "self", ",", "data", ",", "times", ",", "resampled_times", ")", ":", "# pylint: disable=too-many-locals", "# get size of 2d array t x nobs", "nobs", "=", "data", ".", "shape", "[", "-", "1", "]", "if", "self", ".", "interpolate_pixe...
b8c390b9f553c561612fe9eb64e720611633a035
train
InterpolationTask.get_interpolation_function
Initializes interpolation model :param times: Array of reference times in second relative to the first timestamp :type times: numpy.array :param series: One dimensional array of time series :type series: numpy.array :return: Initialized interpolation model class
features/eolearn/features/interpolation.py
def get_interpolation_function(self, times, series): """ Initializes interpolation model :param times: Array of reference times in second relative to the first timestamp :type times: numpy.array :param series: One dimensional array of time series :type series: numpy.array ...
def get_interpolation_function(self, times, series): """ Initializes interpolation model :param times: Array of reference times in second relative to the first timestamp :type times: numpy.array :param series: One dimensional array of time series :type series: numpy.array ...
[ "Initializes", "interpolation", "model" ]
sentinel-hub/eo-learn
python
https://github.com/sentinel-hub/eo-learn/blob/b8c390b9f553c561612fe9eb64e720611633a035/features/eolearn/features/interpolation.py#L286-L295
[ "def", "get_interpolation_function", "(", "self", ",", "times", ",", "series", ")", ":", "return", "self", ".", "interpolation_object", "(", "times", ",", "series", ",", "*", "*", "self", ".", "interpolation_parameters", ")" ]
b8c390b9f553c561612fe9eb64e720611633a035
train
InterpolationTask.get_resampled_timestamp
Takes a list of timestamps and generates new list of timestamps according to ``resample_range`` :param timestamp: list of timestamps :type timestamp: list(datetime.datetime) :return: new list of timestamps :rtype: list(datetime.datetime)
features/eolearn/features/interpolation.py
def get_resampled_timestamp(self, timestamp): """ Takes a list of timestamps and generates new list of timestamps according to ``resample_range`` :param timestamp: list of timestamps :type timestamp: list(datetime.datetime) :return: new list of timestamps :rtype: list(datetime.d...
def get_resampled_timestamp(self, timestamp): """ Takes a list of timestamps and generates new list of timestamps according to ``resample_range`` :param timestamp: list of timestamps :type timestamp: list(datetime.datetime) :return: new list of timestamps :rtype: list(datetime.d...
[ "Takes", "a", "list", "of", "timestamps", "and", "generates", "new", "list", "of", "timestamps", "according", "to", "resample_range" ]
sentinel-hub/eo-learn
python
https://github.com/sentinel-hub/eo-learn/blob/b8c390b9f553c561612fe9eb64e720611633a035/features/eolearn/features/interpolation.py#L297-L326
[ "def", "get_resampled_timestamp", "(", "self", ",", "timestamp", ")", ":", "if", "self", ".", "resample_range", "is", "None", ":", "return", "timestamp", "if", "not", "isinstance", "(", "self", ".", "resample_range", ",", "(", "tuple", ",", "list", ")", ")...
b8c390b9f553c561612fe9eb64e720611633a035
train
InterpolationTask.execute
Execute method that processes EOPatch and returns EOPatch
features/eolearn/features/interpolation.py
def execute(self, eopatch): """ Execute method that processes EOPatch and returns EOPatch """ # pylint: disable=too-many-locals feature_type, feature_name, new_feature_name = next(self.feature(eopatch)) # Make a copy not to change original numpy array feature_data = eopa...
def execute(self, eopatch): """ Execute method that processes EOPatch and returns EOPatch """ # pylint: disable=too-many-locals feature_type, feature_name, new_feature_name = next(self.feature(eopatch)) # Make a copy not to change original numpy array feature_data = eopa...
[ "Execute", "method", "that", "processes", "EOPatch", "and", "returns", "EOPatch" ]
sentinel-hub/eo-learn
python
https://github.com/sentinel-hub/eo-learn/blob/b8c390b9f553c561612fe9eb64e720611633a035/features/eolearn/features/interpolation.py#L328-L386
[ "def", "execute", "(", "self", ",", "eopatch", ")", ":", "# pylint: disable=too-many-locals", "feature_type", ",", "feature_name", ",", "new_feature_name", "=", "next", "(", "self", ".", "feature", "(", "eopatch", ")", ")", "# Make a copy not to change original numpy ...
b8c390b9f553c561612fe9eb64e720611633a035
train
ResamplingTask.interpolate_data
Interpolates data feature :param data: Array in a shape of t x nobs, where nobs = h x w x n :type data: numpy.ndarray :param times: Array of reference times in second relative to the first timestamp :type times: numpy.array :param resampled_times: Array of reference times in sec...
features/eolearn/features/interpolation.py
def interpolate_data(self, data, times, resampled_times): """ Interpolates data feature :param data: Array in a shape of t x nobs, where nobs = h x w x n :type data: numpy.ndarray :param times: Array of reference times in second relative to the first timestamp :type times: numpy...
def interpolate_data(self, data, times, resampled_times): """ Interpolates data feature :param data: Array in a shape of t x nobs, where nobs = h x w x n :type data: numpy.ndarray :param times: Array of reference times in second relative to the first timestamp :type times: numpy...
[ "Interpolates", "data", "feature" ]
sentinel-hub/eo-learn
python
https://github.com/sentinel-hub/eo-learn/blob/b8c390b9f553c561612fe9eb64e720611633a035/features/eolearn/features/interpolation.py#L476-L497
[ "def", "interpolate_data", "(", "self", ",", "data", ",", "times", ",", "resampled_times", ")", ":", "if", "True", "in", "np", ".", "unique", "(", "np", ".", "isnan", "(", "data", ")", ")", ":", "raise", "ValueError", "(", "'Data must not contain any maske...
b8c390b9f553c561612fe9eb64e720611633a035
train
ResamplingTask.get_interpolation_function
Initializes interpolation model :param times: Array of reference times in second relative to the first timestamp :type times: numpy.array :param data: One dimensional array of time series :type data: numpy.array :return: Initialized interpolation model class
features/eolearn/features/interpolation.py
def get_interpolation_function(self, times, data): """ Initializes interpolation model :param times: Array of reference times in second relative to the first timestamp :type times: numpy.array :param data: One dimensional array of time series :type data: numpy.array :ret...
def get_interpolation_function(self, times, data): """ Initializes interpolation model :param times: Array of reference times in second relative to the first timestamp :type times: numpy.array :param data: One dimensional array of time series :type data: numpy.array :ret...
[ "Initializes", "interpolation", "model" ]
sentinel-hub/eo-learn
python
https://github.com/sentinel-hub/eo-learn/blob/b8c390b9f553c561612fe9eb64e720611633a035/features/eolearn/features/interpolation.py#L499-L508
[ "def", "get_interpolation_function", "(", "self", ",", "times", ",", "data", ")", ":", "return", "self", ".", "interpolation_object", "(", "times", ",", "data", ",", "axis", "=", "0", ",", "*", "*", "self", ".", "interpolation_parameters", ")" ]
b8c390b9f553c561612fe9eb64e720611633a035
train
get_text
return inner text in pyquery element
howdoi/howdoi.py
def get_text(element): ''' return inner text in pyquery element ''' _add_links_to_text(element) try: return element.text(squash_space=False) except TypeError: return element.text()
def get_text(element): ''' return inner text in pyquery element ''' _add_links_to_text(element) try: return element.text(squash_space=False) except TypeError: return element.text()
[ "return", "inner", "text", "in", "pyquery", "element" ]
gleitz/howdoi
python
https://github.com/gleitz/howdoi/blob/94f0429b4e99cb914aadfca0f27257ea801471ac/howdoi/howdoi.py#L157-L163
[ "def", "get_text", "(", "element", ")", ":", "_add_links_to_text", "(", "element", ")", "try", ":", "return", "element", ".", "text", "(", "squash_space", "=", "False", ")", "except", "TypeError", ":", "return", "element", ".", "text", "(", ")" ]
94f0429b4e99cb914aadfca0f27257ea801471ac
train
download_file
Simple wrapper around urlretrieve that uses tqdm to display a progress bar of download progress
implicit/datasets/_download.py
def download_file(url, local_filename): """ Simple wrapper around urlretrieve that uses tqdm to display a progress bar of download progress """ local_filename = os.path.abspath(local_filename) path = os.path.dirname(local_filename) if not os.path.isdir(path): os.makedirs(path) with tqdm...
def download_file(url, local_filename): """ Simple wrapper around urlretrieve that uses tqdm to display a progress bar of download progress """ local_filename = os.path.abspath(local_filename) path = os.path.dirname(local_filename) if not os.path.isdir(path): os.makedirs(path) with tqdm...
[ "Simple", "wrapper", "around", "urlretrieve", "that", "uses", "tqdm", "to", "display", "a", "progress", "bar", "of", "download", "progress" ]
benfred/implicit
python
https://github.com/benfred/implicit/blob/6b16c50d1d514a814f2e5b8cf2a829ff23dbba63/implicit/datasets/_download.py#L13-L25
[ "def", "download_file", "(", "url", ",", "local_filename", ")", ":", "local_filename", "=", "os", ".", "path", ".", "abspath", "(", "local_filename", ")", "path", "=", "os", ".", "path", ".", "dirname", "(", "local_filename", ")", "if", "not", "os", ".",...
6b16c50d1d514a814f2e5b8cf2a829ff23dbba63
train
extract_gcc_binaries
Try to find GCC on OSX for OpenMP support.
setup.py
def extract_gcc_binaries(): """Try to find GCC on OSX for OpenMP support.""" patterns = ['/opt/local/bin/g++-mp-[0-9].[0-9]', '/opt/local/bin/g++-mp-[0-9]', '/usr/local/bin/g++-[0-9].[0-9]', '/usr/local/bin/g++-[0-9]'] if 'darwin' in platform.platform().lower(...
def extract_gcc_binaries(): """Try to find GCC on OSX for OpenMP support.""" patterns = ['/opt/local/bin/g++-mp-[0-9].[0-9]', '/opt/local/bin/g++-mp-[0-9]', '/usr/local/bin/g++-[0-9].[0-9]', '/usr/local/bin/g++-[0-9]'] if 'darwin' in platform.platform().lower(...
[ "Try", "to", "find", "GCC", "on", "OSX", "for", "OpenMP", "support", "." ]
benfred/implicit
python
https://github.com/benfred/implicit/blob/6b16c50d1d514a814f2e5b8cf2a829ff23dbba63/setup.py#L81-L98
[ "def", "extract_gcc_binaries", "(", ")", ":", "patterns", "=", "[", "'/opt/local/bin/g++-mp-[0-9].[0-9]'", ",", "'/opt/local/bin/g++-mp-[0-9]'", ",", "'/usr/local/bin/g++-[0-9].[0-9]'", ",", "'/usr/local/bin/g++-[0-9]'", "]", "if", "'darwin'", "in", "platform", ".", "platfo...
6b16c50d1d514a814f2e5b8cf2a829ff23dbba63
train
set_gcc
Try to use GCC on OSX for OpenMP support.
setup.py
def set_gcc(): """Try to use GCC on OSX for OpenMP support.""" # For macports and homebrew if 'darwin' in platform.platform().lower(): gcc = extract_gcc_binaries() if gcc is not None: os.environ["CC"] = gcc os.environ["CXX"] = gcc else: global u...
def set_gcc(): """Try to use GCC on OSX for OpenMP support.""" # For macports and homebrew if 'darwin' in platform.platform().lower(): gcc = extract_gcc_binaries() if gcc is not None: os.environ["CC"] = gcc os.environ["CXX"] = gcc else: global u...
[ "Try", "to", "use", "GCC", "on", "OSX", "for", "OpenMP", "support", "." ]
benfred/implicit
python
https://github.com/benfred/implicit/blob/6b16c50d1d514a814f2e5b8cf2a829ff23dbba63/setup.py#L101-L116
[ "def", "set_gcc", "(", ")", ":", "# For macports and homebrew", "if", "'darwin'", "in", "platform", ".", "platform", "(", ")", ".", "lower", "(", ")", ":", "gcc", "=", "extract_gcc_binaries", "(", ")", "if", "gcc", "is", "not", "None", ":", "os", ".", ...
6b16c50d1d514a814f2e5b8cf2a829ff23dbba63
train
nonzeros
returns the non zeroes of a row in csr_matrix
implicit/utils.py
def nonzeros(m, row): """ returns the non zeroes of a row in csr_matrix """ for index in range(m.indptr[row], m.indptr[row+1]): yield m.indices[index], m.data[index]
def nonzeros(m, row): """ returns the non zeroes of a row in csr_matrix """ for index in range(m.indptr[row], m.indptr[row+1]): yield m.indices[index], m.data[index]
[ "returns", "the", "non", "zeroes", "of", "a", "row", "in", "csr_matrix" ]
benfred/implicit
python
https://github.com/benfred/implicit/blob/6b16c50d1d514a814f2e5b8cf2a829ff23dbba63/implicit/utils.py#L7-L10
[ "def", "nonzeros", "(", "m", ",", "row", ")", ":", "for", "index", "in", "range", "(", "m", ".", "indptr", "[", "row", "]", ",", "m", ".", "indptr", "[", "row", "+", "1", "]", ")", ":", "yield", "m", ".", "indices", "[", "index", "]", ",", ...
6b16c50d1d514a814f2e5b8cf2a829ff23dbba63
train
check_blas_config
checks to see if using OpenBlas/Intel MKL. If so, warn if the number of threads isn't set to 1 (causes severe perf issues when training - can be 10x slower)
implicit/utils.py
def check_blas_config(): """ checks to see if using OpenBlas/Intel MKL. If so, warn if the number of threads isn't set to 1 (causes severe perf issues when training - can be 10x slower) """ # don't warn repeatedly global _checked_blas_config if _checked_blas_config: return _checked_blas_...
def check_blas_config(): """ checks to see if using OpenBlas/Intel MKL. If so, warn if the number of threads isn't set to 1 (causes severe perf issues when training - can be 10x slower) """ # don't warn repeatedly global _checked_blas_config if _checked_blas_config: return _checked_blas_...
[ "checks", "to", "see", "if", "using", "OpenBlas", "/", "Intel", "MKL", ".", "If", "so", "warn", "if", "the", "number", "of", "threads", "isn", "t", "set", "to", "1", "(", "causes", "severe", "perf", "issues", "when", "training", "-", "can", "be", "10...
benfred/implicit
python
https://github.com/benfred/implicit/blob/6b16c50d1d514a814f2e5b8cf2a829ff23dbba63/implicit/utils.py#L16-L31
[ "def", "check_blas_config", "(", ")", ":", "# don't warn repeatedly", "global", "_checked_blas_config", "if", "_checked_blas_config", ":", "return", "_checked_blas_config", "=", "True", "if", "np", ".", "__config__", ".", "get_info", "(", "'openblas_info'", ")", "and"...
6b16c50d1d514a814f2e5b8cf2a829ff23dbba63
train
_read_dataframe
Reads the original dataset PSV as a pandas dataframe
implicit/datasets/sketchfab.py
def _read_dataframe(filename): """ Reads the original dataset PSV as a pandas dataframe """ import pandas # read in triples of user/artist/playcount from the input dataset # get a model based off the input params start = time.time() log.debug("reading data from %s", filename) data = pandas....
def _read_dataframe(filename): """ Reads the original dataset PSV as a pandas dataframe """ import pandas # read in triples of user/artist/playcount from the input dataset # get a model based off the input params start = time.time() log.debug("reading data from %s", filename) data = pandas....
[ "Reads", "the", "original", "dataset", "PSV", "as", "a", "pandas", "dataframe" ]
benfred/implicit
python
https://github.com/benfred/implicit/blob/6b16c50d1d514a814f2e5b8cf2a829ff23dbba63/implicit/datasets/sketchfab.py#L54-L70
[ "def", "_read_dataframe", "(", "filename", ")", ":", "import", "pandas", "# read in triples of user/artist/playcount from the input dataset", "# get a model based off the input params", "start", "=", "time", ".", "time", "(", ")", "log", ".", "debug", "(", "\"reading data f...
6b16c50d1d514a814f2e5b8cf2a829ff23dbba63
train
get_lastfm
Returns the lastfm360k dataset, downloading locally if necessary. Returns a tuple of (artistids, userids, plays) where plays is a CSR matrix
implicit/datasets/lastfm.py
def get_lastfm(): """ Returns the lastfm360k dataset, downloading locally if necessary. Returns a tuple of (artistids, userids, plays) where plays is a CSR matrix """ filename = os.path.join(_download.LOCAL_CACHE_DIR, "lastfm_360k.hdf5") if not os.path.isfile(filename): log.info("Downloading da...
def get_lastfm(): """ Returns the lastfm360k dataset, downloading locally if necessary. Returns a tuple of (artistids, userids, plays) where plays is a CSR matrix """ filename = os.path.join(_download.LOCAL_CACHE_DIR, "lastfm_360k.hdf5") if not os.path.isfile(filename): log.info("Downloading da...
[ "Returns", "the", "lastfm360k", "dataset", "downloading", "locally", "if", "necessary", ".", "Returns", "a", "tuple", "of", "(", "artistids", "userids", "plays", ")", "where", "plays", "is", "a", "CSR", "matrix" ]
benfred/implicit
python
https://github.com/benfred/implicit/blob/6b16c50d1d514a814f2e5b8cf2a829ff23dbba63/implicit/datasets/lastfm.py#L17-L31
[ "def", "get_lastfm", "(", ")", ":", "filename", "=", "os", ".", "path", ".", "join", "(", "_download", ".", "LOCAL_CACHE_DIR", ",", "\"lastfm_360k.hdf5\"", ")", "if", "not", "os", ".", "path", ".", "isfile", "(", "filename", ")", ":", "log", ".", "info...
6b16c50d1d514a814f2e5b8cf2a829ff23dbba63
train
alternating_least_squares
factorizes the matrix Cui using an implicit alternating least squares algorithm. Note: this method is deprecated, consider moving to the AlternatingLeastSquares class instead
implicit/als.py
def alternating_least_squares(Ciu, factors, **kwargs): """ factorizes the matrix Cui using an implicit alternating least squares algorithm. Note: this method is deprecated, consider moving to the AlternatingLeastSquares class instead """ log.warning("This method is deprecated. Please use the Altern...
def alternating_least_squares(Ciu, factors, **kwargs): """ factorizes the matrix Cui using an implicit alternating least squares algorithm. Note: this method is deprecated, consider moving to the AlternatingLeastSquares class instead """ log.warning("This method is deprecated. Please use the Altern...
[ "factorizes", "the", "matrix", "Cui", "using", "an", "implicit", "alternating", "least", "squares", "algorithm", ".", "Note", ":", "this", "method", "is", "deprecated", "consider", "moving", "to", "the", "AlternatingLeastSquares", "class", "instead" ]
benfred/implicit
python
https://github.com/benfred/implicit/blob/6b16c50d1d514a814f2e5b8cf2a829ff23dbba63/implicit/als.py#L297-L308
[ "def", "alternating_least_squares", "(", "Ciu", ",", "factors", ",", "*", "*", "kwargs", ")", ":", "log", ".", "warning", "(", "\"This method is deprecated. Please use the AlternatingLeastSquares\"", "\" class instead\"", ")", "model", "=", "AlternatingLeastSquares", "(",...
6b16c50d1d514a814f2e5b8cf2a829ff23dbba63
train
least_squares
For each user in Cui, calculate factors Xu for them using least squares on Y. Note: this is at least 10 times slower than the cython version included here.
implicit/als.py
def least_squares(Cui, X, Y, regularization, num_threads=0): """ For each user in Cui, calculate factors Xu for them using least squares on Y. Note: this is at least 10 times slower than the cython version included here. """ users, n_factors = X.shape YtY = Y.T.dot(Y) for u in range(us...
def least_squares(Cui, X, Y, regularization, num_threads=0): """ For each user in Cui, calculate factors Xu for them using least squares on Y. Note: this is at least 10 times slower than the cython version included here. """ users, n_factors = X.shape YtY = Y.T.dot(Y) for u in range(us...
[ "For", "each", "user", "in", "Cui", "calculate", "factors", "Xu", "for", "them", "using", "least", "squares", "on", "Y", "." ]
benfred/implicit
python
https://github.com/benfred/implicit/blob/6b16c50d1d514a814f2e5b8cf2a829ff23dbba63/implicit/als.py#L311-L322
[ "def", "least_squares", "(", "Cui", ",", "X", ",", "Y", ",", "regularization", ",", "num_threads", "=", "0", ")", ":", "users", ",", "n_factors", "=", "X", ".", "shape", "YtY", "=", "Y", ".", "T", ".", "dot", "(", "Y", ")", "for", "u", "in", "r...
6b16c50d1d514a814f2e5b8cf2a829ff23dbba63
train
AlternatingLeastSquares.fit
Factorizes the item_users matrix. After calling this method, the members 'user_factors' and 'item_factors' will be initialized with a latent factor model of the input data. The item_users matrix does double duty here. It defines which items are liked by which users (P_iu in the origina...
implicit/als.py
def fit(self, item_users, show_progress=True): """ Factorizes the item_users matrix. After calling this method, the members 'user_factors' and 'item_factors' will be initialized with a latent factor model of the input data. The item_users matrix does double duty here. It defines which ...
def fit(self, item_users, show_progress=True): """ Factorizes the item_users matrix. After calling this method, the members 'user_factors' and 'item_factors' will be initialized with a latent factor model of the input data. The item_users matrix does double duty here. It defines which ...
[ "Factorizes", "the", "item_users", "matrix", "." ]
benfred/implicit
python
https://github.com/benfred/implicit/blob/6b16c50d1d514a814f2e5b8cf2a829ff23dbba63/implicit/als.py#L96-L175
[ "def", "fit", "(", "self", ",", "item_users", ",", "show_progress", "=", "True", ")", ":", "Ciu", "=", "item_users", "if", "not", "isinstance", "(", "Ciu", ",", "scipy", ".", "sparse", ".", "csr_matrix", ")", ":", "s", "=", "time", ".", "time", "(", ...
6b16c50d1d514a814f2e5b8cf2a829ff23dbba63
train
AlternatingLeastSquares._fit_gpu
specialized training on the gpu. copies inputs to/from cuda device
implicit/als.py
def _fit_gpu(self, Ciu_host, Cui_host, show_progress=True): """ specialized training on the gpu. copies inputs to/from cuda device """ if not implicit.cuda.HAS_CUDA: raise ValueError("No CUDA extension has been built, can't train on GPU.") if self.dtype == np.float64: lo...
def _fit_gpu(self, Ciu_host, Cui_host, show_progress=True): """ specialized training on the gpu. copies inputs to/from cuda device """ if not implicit.cuda.HAS_CUDA: raise ValueError("No CUDA extension has been built, can't train on GPU.") if self.dtype == np.float64: lo...
[ "specialized", "training", "on", "the", "gpu", ".", "copies", "inputs", "to", "/", "from", "cuda", "device" ]
benfred/implicit
python
https://github.com/benfred/implicit/blob/6b16c50d1d514a814f2e5b8cf2a829ff23dbba63/implicit/als.py#L177-L214
[ "def", "_fit_gpu", "(", "self", ",", "Ciu_host", ",", "Cui_host", ",", "show_progress", "=", "True", ")", ":", "if", "not", "implicit", ".", "cuda", ".", "HAS_CUDA", ":", "raise", "ValueError", "(", "\"No CUDA extension has been built, can't train on GPU.\"", ")",...
6b16c50d1d514a814f2e5b8cf2a829ff23dbba63
train
AlternatingLeastSquares.explain
Provides explanations for why the item is liked by the user. Parameters --------- userid : int The userid to explain recommendations for user_items : csr_matrix Sparse matrix containing the liked items for the user itemid : int The itemid to e...
implicit/als.py
def explain(self, userid, user_items, itemid, user_weights=None, N=10): """ Provides explanations for why the item is liked by the user. Parameters --------- userid : int The userid to explain recommendations for user_items : csr_matrix Sparse matrix cont...
def explain(self, userid, user_items, itemid, user_weights=None, N=10): """ Provides explanations for why the item is liked by the user. Parameters --------- userid : int The userid to explain recommendations for user_items : csr_matrix Sparse matrix cont...
[ "Provides", "explanations", "for", "why", "the", "item", "is", "liked", "by", "the", "user", "." ]
benfred/implicit
python
https://github.com/benfred/implicit/blob/6b16c50d1d514a814f2e5b8cf2a829ff23dbba63/implicit/als.py#L221-L280
[ "def", "explain", "(", "self", ",", "userid", ",", "user_items", ",", "itemid", ",", "user_weights", "=", "None", ",", "N", "=", "10", ")", ":", "# user_weights = Cholesky decomposition of Wu^-1", "# from section 5 of the paper CF for Implicit Feedback Datasets", "user_it...
6b16c50d1d514a814f2e5b8cf2a829ff23dbba63
train
augment_inner_product_matrix
This function transforms a factor matrix such that an angular nearest neighbours search will return top related items of the inner product. This involves transforming each row by adding one extra dimension as suggested in the paper: "Speeding Up the Xbox Recommender System Using a Euclidean Transformation ...
implicit/approximate_als.py
def augment_inner_product_matrix(factors): """ This function transforms a factor matrix such that an angular nearest neighbours search will return top related items of the inner product. This involves transforming each row by adding one extra dimension as suggested in the paper: "Speeding Up the Xbox R...
def augment_inner_product_matrix(factors): """ This function transforms a factor matrix such that an angular nearest neighbours search will return top related items of the inner product. This involves transforming each row by adding one extra dimension as suggested in the paper: "Speeding Up the Xbox R...
[ "This", "function", "transforms", "a", "factor", "matrix", "such", "that", "an", "angular", "nearest", "neighbours", "search", "will", "return", "top", "related", "items", "of", "the", "inner", "product", "." ]
benfred/implicit
python
https://github.com/benfred/implicit/blob/6b16c50d1d514a814f2e5b8cf2a829ff23dbba63/implicit/approximate_als.py#L18-L35
[ "def", "augment_inner_product_matrix", "(", "factors", ")", ":", "norms", "=", "numpy", ".", "linalg", ".", "norm", "(", "factors", ",", "axis", "=", "1", ")", "max_norm", "=", "norms", ".", "max", "(", ")", "# add an extra dimension so that the norm of each row...
6b16c50d1d514a814f2e5b8cf2a829ff23dbba63
train
convert_sparse_to_dataframe
Converts a scipy sparse matrix to a spark dataframe
benchmarks/benchmark_spark.py
def convert_sparse_to_dataframe(spark, context, sparse_matrix): """ Converts a scipy sparse matrix to a spark dataframe """ m = sparse_matrix.tocoo() data = context.parallelize(numpy.array([m.row, m.col, m.data]).T, numSlices=len(m.row)/1024) return spark.createDataFrame(d...
def convert_sparse_to_dataframe(spark, context, sparse_matrix): """ Converts a scipy sparse matrix to a spark dataframe """ m = sparse_matrix.tocoo() data = context.parallelize(numpy.array([m.row, m.col, m.data]).T, numSlices=len(m.row)/1024) return spark.createDataFrame(d...
[ "Converts", "a", "scipy", "sparse", "matrix", "to", "a", "spark", "dataframe" ]
benfred/implicit
python
https://github.com/benfred/implicit/blob/6b16c50d1d514a814f2e5b8cf2a829ff23dbba63/benchmarks/benchmark_spark.py#L20-L27
[ "def", "convert_sparse_to_dataframe", "(", "spark", ",", "context", ",", "sparse_matrix", ")", ":", "m", "=", "sparse_matrix", ".", "tocoo", "(", ")", "data", "=", "context", ".", "parallelize", "(", "numpy", ".", "array", "(", "[", "m", ".", "row", ",",...
6b16c50d1d514a814f2e5b8cf2a829ff23dbba63
train
generate_dataset
Generates a hdf5 datasetfile from the raw datafiles: You will need to download the train_triplets from here: https://labrosa.ee.columbia.edu/millionsong/tasteprofile#getting And the 'Summary File of the whole dataset' from here https://labrosa.ee.columbia.edu/millionsong/pages/getting-dataset ...
implicit/datasets/million_song_dataset.py
def generate_dataset(triplets_filename, summary_filename="msd_summary_file.h5", outputfilename="msd_taste_profile.hdf5"): """ Generates a hdf5 datasetfile from the raw datafiles: You will need to download the train_triplets from here: https://labrosa.ee.columbia.edu/millionsong/tas...
def generate_dataset(triplets_filename, summary_filename="msd_summary_file.h5", outputfilename="msd_taste_profile.hdf5"): """ Generates a hdf5 datasetfile from the raw datafiles: You will need to download the train_triplets from here: https://labrosa.ee.columbia.edu/millionsong/tas...
[ "Generates", "a", "hdf5", "datasetfile", "from", "the", "raw", "datafiles", ":" ]
benfred/implicit
python
https://github.com/benfred/implicit/blob/6b16c50d1d514a814f2e5b8cf2a829ff23dbba63/implicit/datasets/million_song_dataset.py#L44-L59
[ "def", "generate_dataset", "(", "triplets_filename", ",", "summary_filename", "=", "\"msd_summary_file.h5\"", ",", "outputfilename", "=", "\"msd_taste_profile.hdf5\"", ")", ":", "data", "=", "_read_triplets_dataframe", "(", "triplets_filename", ")", "track_info", "=", "_j...
6b16c50d1d514a814f2e5b8cf2a829ff23dbba63
train
_read_triplets_dataframe
Reads the original dataset TSV as a pandas dataframe
implicit/datasets/million_song_dataset.py
def _read_triplets_dataframe(filename): """ Reads the original dataset TSV as a pandas dataframe """ # delay importing this to avoid another dependency import pandas # read in triples of user/artist/playcount from the input dataset # get a model based off the input params start = time.time() ...
def _read_triplets_dataframe(filename): """ Reads the original dataset TSV as a pandas dataframe """ # delay importing this to avoid another dependency import pandas # read in triples of user/artist/playcount from the input dataset # get a model based off the input params start = time.time() ...
[ "Reads", "the", "original", "dataset", "TSV", "as", "a", "pandas", "dataframe" ]
benfred/implicit
python
https://github.com/benfred/implicit/blob/6b16c50d1d514a814f2e5b8cf2a829ff23dbba63/implicit/datasets/million_song_dataset.py#L62-L80
[ "def", "_read_triplets_dataframe", "(", "filename", ")", ":", "# delay importing this to avoid another dependency", "import", "pandas", "# read in triples of user/artist/playcount from the input dataset", "# get a model based off the input params", "start", "=", "time", ".", "time", ...
6b16c50d1d514a814f2e5b8cf2a829ff23dbba63
train
_join_summary_file
Gets the trackinfo array by joining taste profile to the track summary file
implicit/datasets/million_song_dataset.py
def _join_summary_file(data, summary_filename="msd_summary_file.h5"): """ Gets the trackinfo array by joining taste profile to the track summary file """ msd = h5py.File(summary_filename) # create a lookup table of trackid -> position track_lookup = dict((t.encode("utf8"), i) for i, t in enumerate(data...
def _join_summary_file(data, summary_filename="msd_summary_file.h5"): """ Gets the trackinfo array by joining taste profile to the track summary file """ msd = h5py.File(summary_filename) # create a lookup table of trackid -> position track_lookup = dict((t.encode("utf8"), i) for i, t in enumerate(data...
[ "Gets", "the", "trackinfo", "array", "by", "joining", "taste", "profile", "to", "the", "track", "summary", "file" ]
benfred/implicit
python
https://github.com/benfred/implicit/blob/6b16c50d1d514a814f2e5b8cf2a829ff23dbba63/implicit/datasets/million_song_dataset.py#L83-L100
[ "def", "_join_summary_file", "(", "data", ",", "summary_filename", "=", "\"msd_summary_file.h5\"", ")", ":", "msd", "=", "h5py", ".", "File", "(", "summary_filename", ")", "# create a lookup table of trackid -> position", "track_lookup", "=", "dict", "(", "(", "t", ...
6b16c50d1d514a814f2e5b8cf2a829ff23dbba63
train
tfidf_weight
Weights a Sparse Matrix by TF-IDF Weighted
implicit/nearest_neighbours.py
def tfidf_weight(X): """ Weights a Sparse Matrix by TF-IDF Weighted """ X = coo_matrix(X) # calculate IDF N = float(X.shape[0]) idf = log(N) - log1p(bincount(X.col)) # apply TF-IDF adjustment X.data = sqrt(X.data) * idf[X.col] return X
def tfidf_weight(X): """ Weights a Sparse Matrix by TF-IDF Weighted """ X = coo_matrix(X) # calculate IDF N = float(X.shape[0]) idf = log(N) - log1p(bincount(X.col)) # apply TF-IDF adjustment X.data = sqrt(X.data) * idf[X.col] return X
[ "Weights", "a", "Sparse", "Matrix", "by", "TF", "-", "IDF", "Weighted" ]
benfred/implicit
python
https://github.com/benfred/implicit/blob/6b16c50d1d514a814f2e5b8cf2a829ff23dbba63/implicit/nearest_neighbours.py#L137-L147
[ "def", "tfidf_weight", "(", "X", ")", ":", "X", "=", "coo_matrix", "(", "X", ")", "# calculate IDF", "N", "=", "float", "(", "X", ".", "shape", "[", "0", "]", ")", "idf", "=", "log", "(", "N", ")", "-", "log1p", "(", "bincount", "(", "X", ".", ...
6b16c50d1d514a814f2e5b8cf2a829ff23dbba63
train
normalize
equivalent to scipy.preprocessing.normalize on sparse matrices , but lets avoid another depedency just for a small utility function
implicit/nearest_neighbours.py
def normalize(X): """ equivalent to scipy.preprocessing.normalize on sparse matrices , but lets avoid another depedency just for a small utility function """ X = coo_matrix(X) X.data = X.data / sqrt(bincount(X.row, X.data ** 2))[X.row] return X
def normalize(X): """ equivalent to scipy.preprocessing.normalize on sparse matrices , but lets avoid another depedency just for a small utility function """ X = coo_matrix(X) X.data = X.data / sqrt(bincount(X.row, X.data ** 2))[X.row] return X
[ "equivalent", "to", "scipy", ".", "preprocessing", ".", "normalize", "on", "sparse", "matrices", "but", "lets", "avoid", "another", "depedency", "just", "for", "a", "small", "utility", "function" ]
benfred/implicit
python
https://github.com/benfred/implicit/blob/6b16c50d1d514a814f2e5b8cf2a829ff23dbba63/implicit/nearest_neighbours.py#L150-L155
[ "def", "normalize", "(", "X", ")", ":", "X", "=", "coo_matrix", "(", "X", ")", "X", ".", "data", "=", "X", ".", "data", "/", "sqrt", "(", "bincount", "(", "X", ".", "row", ",", "X", ".", "data", "**", "2", ")", ")", "[", "X", ".", "row", ...
6b16c50d1d514a814f2e5b8cf2a829ff23dbba63
train
bm25_weight
Weighs each row of a sparse matrix X by BM25 weighting
implicit/nearest_neighbours.py
def bm25_weight(X, K1=100, B=0.8): """ Weighs each row of a sparse matrix X by BM25 weighting """ # calculate idf per term (user) X = coo_matrix(X) N = float(X.shape[0]) idf = log(N) - log1p(bincount(X.col)) # calculate length_norm per document (artist) row_sums = numpy.ravel(X.sum(axis=1...
def bm25_weight(X, K1=100, B=0.8): """ Weighs each row of a sparse matrix X by BM25 weighting """ # calculate idf per term (user) X = coo_matrix(X) N = float(X.shape[0]) idf = log(N) - log1p(bincount(X.col)) # calculate length_norm per document (artist) row_sums = numpy.ravel(X.sum(axis=1...
[ "Weighs", "each", "row", "of", "a", "sparse", "matrix", "X", "by", "BM25", "weighting" ]
benfred/implicit
python
https://github.com/benfred/implicit/blob/6b16c50d1d514a814f2e5b8cf2a829ff23dbba63/implicit/nearest_neighbours.py#L158-L173
[ "def", "bm25_weight", "(", "X", ",", "K1", "=", "100", ",", "B", "=", "0.8", ")", ":", "# calculate idf per term (user)", "X", "=", "coo_matrix", "(", "X", ")", "N", "=", "float", "(", "X", ".", "shape", "[", "0", "]", ")", "idf", "=", "log", "("...
6b16c50d1d514a814f2e5b8cf2a829ff23dbba63
train
ItemItemRecommender.fit
Computes and stores the similarity matrix
implicit/nearest_neighbours.py
def fit(self, weighted, show_progress=True): """ Computes and stores the similarity matrix """ self.similarity = all_pairs_knn(weighted, self.K, show_progress=show_progress, num_threads=self.num_threads).tocsr() self...
def fit(self, weighted, show_progress=True): """ Computes and stores the similarity matrix """ self.similarity = all_pairs_knn(weighted, self.K, show_progress=show_progress, num_threads=self.num_threads).tocsr() self...
[ "Computes", "and", "stores", "the", "similarity", "matrix" ]
benfred/implicit
python
https://github.com/benfred/implicit/blob/6b16c50d1d514a814f2e5b8cf2a829ff23dbba63/implicit/nearest_neighbours.py#L31-L36
[ "def", "fit", "(", "self", ",", "weighted", ",", "show_progress", "=", "True", ")", ":", "self", ".", "similarity", "=", "all_pairs_knn", "(", "weighted", ",", "self", ".", "K", ",", "show_progress", "=", "show_progress", ",", "num_threads", "=", "self", ...
6b16c50d1d514a814f2e5b8cf2a829ff23dbba63
train
ItemItemRecommender.recommend
returns the best N recommendations for a user given its id
implicit/nearest_neighbours.py
def recommend(self, userid, user_items, N=10, filter_already_liked_items=True, filter_items=None, recalculate_user=False): """ returns the best N recommendations for a user given its id""" if userid >= user_items.shape[0]: raise ValueError("userid is out of bounds of the us...
def recommend(self, userid, user_items, N=10, filter_already_liked_items=True, filter_items=None, recalculate_user=False): """ returns the best N recommendations for a user given its id""" if userid >= user_items.shape[0]: raise ValueError("userid is out of bounds of the us...
[ "returns", "the", "best", "N", "recommendations", "for", "a", "user", "given", "its", "id" ]
benfred/implicit
python
https://github.com/benfred/implicit/blob/6b16c50d1d514a814f2e5b8cf2a829ff23dbba63/implicit/nearest_neighbours.py#L38-L58
[ "def", "recommend", "(", "self", ",", "userid", ",", "user_items", ",", "N", "=", "10", ",", "filter_already_liked_items", "=", "True", ",", "filter_items", "=", "None", ",", "recalculate_user", "=", "False", ")", ":", "if", "userid", ">=", "user_items", "...
6b16c50d1d514a814f2e5b8cf2a829ff23dbba63
train
ItemItemRecommender.rank_items
Rank given items for a user and returns sorted item list
implicit/nearest_neighbours.py
def rank_items(self, userid, user_items, selected_items, recalculate_user=False): """ Rank given items for a user and returns sorted item list """ # check if selected_items contains itemids that are not in the model(user_items) if max(selected_items) >= user_items.shape[1] or min(selected_items)...
def rank_items(self, userid, user_items, selected_items, recalculate_user=False): """ Rank given items for a user and returns sorted item list """ # check if selected_items contains itemids that are not in the model(user_items) if max(selected_items) >= user_items.shape[1] or min(selected_items)...
[ "Rank", "given", "items", "for", "a", "user", "and", "returns", "sorted", "item", "list" ]
benfred/implicit
python
https://github.com/benfred/implicit/blob/6b16c50d1d514a814f2e5b8cf2a829ff23dbba63/implicit/nearest_neighbours.py#L60-L78
[ "def", "rank_items", "(", "self", ",", "userid", ",", "user_items", ",", "selected_items", ",", "recalculate_user", "=", "False", ")", ":", "# check if selected_items contains itemids that are not in the model(user_items)", "if", "max", "(", "selected_items", ")", ">=", ...
6b16c50d1d514a814f2e5b8cf2a829ff23dbba63
train
ItemItemRecommender.similar_items
Returns a list of the most similar other items
implicit/nearest_neighbours.py
def similar_items(self, itemid, N=10): """ Returns a list of the most similar other items """ if itemid >= self.similarity.shape[0]: return [] return sorted(list(nonzeros(self.similarity, itemid)), key=lambda x: -x[1])[:N]
def similar_items(self, itemid, N=10): """ Returns a list of the most similar other items """ if itemid >= self.similarity.shape[0]: return [] return sorted(list(nonzeros(self.similarity, itemid)), key=lambda x: -x[1])[:N]
[ "Returns", "a", "list", "of", "the", "most", "similar", "other", "items" ]
benfred/implicit
python
https://github.com/benfred/implicit/blob/6b16c50d1d514a814f2e5b8cf2a829ff23dbba63/implicit/nearest_neighbours.py#L83-L88
[ "def", "similar_items", "(", "self", ",", "itemid", ",", "N", "=", "10", ")", ":", "if", "itemid", ">=", "self", ".", "similarity", ".", "shape", "[", "0", "]", ":", "return", "[", "]", "return", "sorted", "(", "list", "(", "nonzeros", "(", "self",...
6b16c50d1d514a814f2e5b8cf2a829ff23dbba63
train
get_reddit
Returns the reddit dataset, downloading locally if necessary. This dataset was released here: https://www.reddit.com/r/redditdev/comments/dtg4j/want_to_help_reddit_build_a_recommender_a_public/ and contains 23M up/down votes from 44K users on 3.4M links. Returns a CSR matrix of (item, user, rating
implicit/datasets/reddit.py
def get_reddit(): """ Returns the reddit dataset, downloading locally if necessary. This dataset was released here: https://www.reddit.com/r/redditdev/comments/dtg4j/want_to_help_reddit_build_a_recommender_a_public/ and contains 23M up/down votes from 44K users on 3.4M links. Returns a CSR matrix ...
def get_reddit(): """ Returns the reddit dataset, downloading locally if necessary. This dataset was released here: https://www.reddit.com/r/redditdev/comments/dtg4j/want_to_help_reddit_build_a_recommender_a_public/ and contains 23M up/down votes from 44K users on 3.4M links. Returns a CSR matrix ...
[ "Returns", "the", "reddit", "dataset", "downloading", "locally", "if", "necessary", "." ]
benfred/implicit
python
https://github.com/benfred/implicit/blob/6b16c50d1d514a814f2e5b8cf2a829ff23dbba63/implicit/datasets/reddit.py#L17-L35
[ "def", "get_reddit", "(", ")", ":", "filename", "=", "os", ".", "path", ".", "join", "(", "_download", ".", "LOCAL_CACHE_DIR", ",", "\"reddit.hdf5\"", ")", "if", "not", "os", ".", "path", ".", "isfile", "(", "filename", ")", ":", "log", ".", "info", ...
6b16c50d1d514a814f2e5b8cf2a829ff23dbba63
train
_read_dataframe
Reads the original dataset TSV as a pandas dataframe
implicit/datasets/reddit.py
def _read_dataframe(filename): """ Reads the original dataset TSV as a pandas dataframe """ # delay importing this to avoid another dependency import pandas # read in triples of user/artist/playcount from the input dataset # get a model based off the input params start = time.time() log.deb...
def _read_dataframe(filename): """ Reads the original dataset TSV as a pandas dataframe """ # delay importing this to avoid another dependency import pandas # read in triples of user/artist/playcount from the input dataset # get a model based off the input params start = time.time() log.deb...
[ "Reads", "the", "original", "dataset", "TSV", "as", "a", "pandas", "dataframe" ]
benfred/implicit
python
https://github.com/benfred/implicit/blob/6b16c50d1d514a814f2e5b8cf2a829ff23dbba63/implicit/datasets/reddit.py#L49-L66
[ "def", "_read_dataframe", "(", "filename", ")", ":", "# delay importing this to avoid another dependency", "import", "pandas", "# read in triples of user/artist/playcount from the input dataset", "# get a model based off the input params", "start", "=", "time", ".", "time", "(", ")...
6b16c50d1d514a814f2e5b8cf2a829ff23dbba63
train
get_movielens
Gets movielens datasets Parameters --------- variant : string Which version of the movielens dataset to download. Should be one of '20m', '10m', '1m' or '100k'. Returns ------- movies : ndarray An array of the movie titles. ratings : csr_matrix A sparse matr...
implicit/datasets/movielens.py
def get_movielens(variant="20m"): """ Gets movielens datasets Parameters --------- variant : string Which version of the movielens dataset to download. Should be one of '20m', '10m', '1m' or '100k'. Returns ------- movies : ndarray An array of the movie titles. ...
def get_movielens(variant="20m"): """ Gets movielens datasets Parameters --------- variant : string Which version of the movielens dataset to download. Should be one of '20m', '10m', '1m' or '100k'. Returns ------- movies : ndarray An array of the movie titles. ...
[ "Gets", "movielens", "datasets" ]
benfred/implicit
python
https://github.com/benfred/implicit/blob/6b16c50d1d514a814f2e5b8cf2a829ff23dbba63/implicit/datasets/movielens.py#L16-L45
[ "def", "get_movielens", "(", "variant", "=", "\"20m\"", ")", ":", "filename", "=", "\"movielens_%s.hdf5\"", "%", "variant", "path", "=", "os", ".", "path", ".", "join", "(", "_download", ".", "LOCAL_CACHE_DIR", ",", "filename", ")", "if", "not", "os", ".",...
6b16c50d1d514a814f2e5b8cf2a829ff23dbba63
train
generate_dataset
Generates a hdf5 movielens datasetfile from the raw datafiles found at: https://grouplens.org/datasets/movielens/20m/ You shouldn't have to run this yourself, and can instead just download the output using the 'get_movielens' funciton./
implicit/datasets/movielens.py
def generate_dataset(path, variant='20m', outputpath="."): """ Generates a hdf5 movielens datasetfile from the raw datafiles found at: https://grouplens.org/datasets/movielens/20m/ You shouldn't have to run this yourself, and can instead just download the output using the 'get_movielens' funciton./ ...
def generate_dataset(path, variant='20m', outputpath="."): """ Generates a hdf5 movielens datasetfile from the raw datafiles found at: https://grouplens.org/datasets/movielens/20m/ You shouldn't have to run this yourself, and can instead just download the output using the 'get_movielens' funciton./ ...
[ "Generates", "a", "hdf5", "movielens", "datasetfile", "from", "the", "raw", "datafiles", "found", "at", ":", "https", ":", "//", "grouplens", ".", "org", "/", "datasets", "/", "movielens", "/", "20m", "/" ]
benfred/implicit
python
https://github.com/benfred/implicit/blob/6b16c50d1d514a814f2e5b8cf2a829ff23dbba63/implicit/datasets/movielens.py#L48-L64
[ "def", "generate_dataset", "(", "path", ",", "variant", "=", "'20m'", ",", "outputpath", "=", "\".\"", ")", ":", "filename", "=", "os", ".", "path", ".", "join", "(", "outputpath", ",", "\"movielens_%s.hdf5\"", "%", "variant", ")", "if", "variant", "==", ...
6b16c50d1d514a814f2e5b8cf2a829ff23dbba63
train
_read_dataframes_20M
reads in the movielens 20M
implicit/datasets/movielens.py
def _read_dataframes_20M(path): """ reads in the movielens 20M""" import pandas ratings = pandas.read_csv(os.path.join(path, "ratings.csv")) movies = pandas.read_csv(os.path.join(path, "movies.csv")) return ratings, movies
def _read_dataframes_20M(path): """ reads in the movielens 20M""" import pandas ratings = pandas.read_csv(os.path.join(path, "ratings.csv")) movies = pandas.read_csv(os.path.join(path, "movies.csv")) return ratings, movies
[ "reads", "in", "the", "movielens", "20M" ]
benfred/implicit
python
https://github.com/benfred/implicit/blob/6b16c50d1d514a814f2e5b8cf2a829ff23dbba63/implicit/datasets/movielens.py#L67-L74
[ "def", "_read_dataframes_20M", "(", "path", ")", ":", "import", "pandas", "ratings", "=", "pandas", ".", "read_csv", "(", "os", ".", "path", ".", "join", "(", "path", ",", "\"ratings.csv\"", ")", ")", "movies", "=", "pandas", ".", "read_csv", "(", "os", ...
6b16c50d1d514a814f2e5b8cf2a829ff23dbba63
train
_read_dataframes_100k
reads in the movielens 100k dataset
implicit/datasets/movielens.py
def _read_dataframes_100k(path): """ reads in the movielens 100k dataset""" import pandas ratings = pandas.read_table(os.path.join(path, "u.data"), names=['userId', 'movieId', 'rating', 'timestamp']) movies = pandas.read_csv(os.path.join(path, "u.item"), ...
def _read_dataframes_100k(path): """ reads in the movielens 100k dataset""" import pandas ratings = pandas.read_table(os.path.join(path, "u.data"), names=['userId', 'movieId', 'rating', 'timestamp']) movies = pandas.read_csv(os.path.join(path, "u.item"), ...
[ "reads", "in", "the", "movielens", "100k", "dataset" ]
benfred/implicit
python
https://github.com/benfred/implicit/blob/6b16c50d1d514a814f2e5b8cf2a829ff23dbba63/implicit/datasets/movielens.py#L77-L90
[ "def", "_read_dataframes_100k", "(", "path", ")", ":", "import", "pandas", "ratings", "=", "pandas", ".", "read_table", "(", "os", ".", "path", ".", "join", "(", "path", ",", "\"u.data\"", ")", ",", "names", "=", "[", "'userId'", ",", "'movieId'", ",", ...
6b16c50d1d514a814f2e5b8cf2a829ff23dbba63
train
RecommenderBase.recommend
Recommends items for a user Calculates the N best recommendations for a user, and returns a list of itemids, score. Parameters ---------- userid : int The userid to calculate recommendations for user_items : csr_matrix A sparse matrix of shape (number_us...
implicit/recommender_base.py
def recommend(self, userid, user_items, N=10, filter_already_liked_items=True, filter_items=None, recalculate_user=False): """ Recommends items for a user Calculates the N best recommendations for a user, and returns a list of itemids, score. Parameters ------...
def recommend(self, userid, user_items, N=10, filter_already_liked_items=True, filter_items=None, recalculate_user=False): """ Recommends items for a user Calculates the N best recommendations for a user, and returns a list of itemids, score. Parameters ------...
[ "Recommends", "items", "for", "a", "user" ]
benfred/implicit
python
https://github.com/benfred/implicit/blob/6b16c50d1d514a814f2e5b8cf2a829ff23dbba63/implicit/recommender_base.py#L28-L57
[ "def", "recommend", "(", "self", ",", "userid", ",", "user_items", ",", "N", "=", "10", ",", "filter_already_liked_items", "=", "True", ",", "filter_items", "=", "None", ",", "recalculate_user", "=", "False", ")", ":", "pass" ]
6b16c50d1d514a814f2e5b8cf2a829ff23dbba63
train
find_in_path
Find a file in a search path
cuda_setup.py
def find_in_path(name, path): "Find a file in a search path" # adapted fom http://code.activestate.com/recipes/52224-find-a-file-given-a-search-path/ for dir in path.split(os.pathsep): binpath = os.path.join(dir, name) if os.path.exists(binpath): return os.path.abspath(binpath) ...
def find_in_path(name, path): "Find a file in a search path" # adapted fom http://code.activestate.com/recipes/52224-find-a-file-given-a-search-path/ for dir in path.split(os.pathsep): binpath = os.path.join(dir, name) if os.path.exists(binpath): return os.path.abspath(binpath) ...
[ "Find", "a", "file", "in", "a", "search", "path" ]
benfred/implicit
python
https://github.com/benfred/implicit/blob/6b16c50d1d514a814f2e5b8cf2a829ff23dbba63/cuda_setup.py#L11-L18
[ "def", "find_in_path", "(", "name", ",", "path", ")", ":", "# adapted fom http://code.activestate.com/recipes/52224-find-a-file-given-a-search-path/", "for", "dir", "in", "path", ".", "split", "(", "os", ".", "pathsep", ")", ":", "binpath", "=", "os", ".", "path", ...
6b16c50d1d514a814f2e5b8cf2a829ff23dbba63
train
locate_cuda
Locate the CUDA environment on the system If a valid cuda installation is found this returns a dict with keys 'home', 'nvcc', 'include', and 'lib64' and values giving the absolute path to each directory. Starts by looking for the CUDAHOME env variable. If not found, everything is based on finding 'nvc...
cuda_setup.py
def locate_cuda(): """Locate the CUDA environment on the system If a valid cuda installation is found this returns a dict with keys 'home', 'nvcc', 'include', and 'lib64' and values giving the absolute path to each directory. Starts by looking for the CUDAHOME env variable. If not found, everything is...
def locate_cuda(): """Locate the CUDA environment on the system If a valid cuda installation is found this returns a dict with keys 'home', 'nvcc', 'include', and 'lib64' and values giving the absolute path to each directory. Starts by looking for the CUDAHOME env variable. If not found, everything is...
[ "Locate", "the", "CUDA", "environment", "on", "the", "system" ]
benfred/implicit
python
https://github.com/benfred/implicit/blob/6b16c50d1d514a814f2e5b8cf2a829ff23dbba63/cuda_setup.py#L21-L74
[ "def", "locate_cuda", "(", ")", ":", "nvcc_bin", "=", "'nvcc'", "if", "sys", ".", "platform", ".", "startswith", "(", "\"win\"", ")", ":", "nvcc_bin", "=", "'nvcc.exe'", "# first check if the CUDAHOME env variable is in use", "if", "'CUDAHOME'", "in", "os", ".", ...
6b16c50d1d514a814f2e5b8cf2a829ff23dbba63