INSTRUCTION stringlengths 1 8.43k | RESPONSE stringlengths 75 104k |
|---|---|
Creates new H2OWord2vecEstimator based on an external model.: param external: H2OFrame with an external model: return: H2OWord2vecEstimator instance representing the external model | def from_external(external=H2OFrame):
"""
Creates new H2OWord2vecEstimator based on an external model.
:param external: H2OFrame with an external model
:return: H2OWord2vecEstimator instance representing the external model
"""
w2v_model = H2OWord2vecEstimator(pre_trained=... |
Determines vec_size for a pre - trained model after basic model verification. | def _determine_vec_size(self):
"""
Determines vec_size for a pre-trained model after basic model verification.
"""
first_column = self.pre_trained.types[self.pre_trained.columns[0]]
if first_column != 'string':
raise H2OValueError("First column of given pre_trained m... |
Mean absolute error regression loss. | def h2o_mean_absolute_error(y_actual, y_predicted, weights=None):
"""
Mean absolute error regression loss.
:param y_actual: H2OFrame of actual response.
:param y_predicted: H2OFrame of predicted response.
:param weights: (Optional) sample weights
:returns: mean absolute error loss (best is 0.0)... |
Mean squared error regression loss | def h2o_mean_squared_error(y_actual, y_predicted, weights=None):
"""
Mean squared error regression loss
:param y_actual: H2OFrame of actual response.
:param y_predicted: H2OFrame of predicted response.
:param weights: (Optional) sample weights
:returns: mean squared error loss (best is 0.0).
... |
Median absolute error regression loss | def h2o_median_absolute_error(y_actual, y_predicted):
"""
Median absolute error regression loss
:param y_actual: H2OFrame of actual response.
:param y_predicted: H2OFrame of predicted response.
:returns: median absolute error loss (best is 0.0)
"""
ModelBase._check_targets(y_actual, y_predi... |
Explained variance regression score function. | def h2o_explained_variance_score(y_actual, y_predicted, weights=None):
"""
Explained variance regression score function.
:param y_actual: H2OFrame of actual response.
:param y_predicted: H2OFrame of predicted response.
:param weights: (Optional) sample weights
:returns: the explained variance s... |
R - squared ( coefficient of determination ) regression score function | def h2o_r2_score(y_actual, y_predicted, weights=1.):
"""
R-squared (coefficient of determination) regression score function
:param y_actual: H2OFrame of actual response.
:param y_predicted: H2OFrame of predicted response.
:param weights: (Optional) sample weights
:returns: R-squared (best is 1.... |
Plots training set ( and validation set if available ) scoring history for an H2ORegressionModel. The timestep and metric arguments are restricted to what is available in its scoring history. | def plot(self, timestep="AUTO", metric="AUTO", **kwargs):
"""
Plots training set (and validation set if available) scoring history for an H2ORegressionModel. The timestep
and metric arguments are restricted to what is available in its scoring history.
:param timestep: A unit of measurem... |
Assert that the argument has the specified type. | def assert_is_type(var, *types, **kwargs):
"""
Assert that the argument has the specified type.
This function is used to check that the type of the argument is correct, otherwises it raises an H2OTypeError.
See more details in the module's help.
:param var: variable to check
:param types: the ... |
Assert that string variable matches the provided regular expression. | def assert_matches(v, regex):
"""
Assert that string variable matches the provided regular expression.
:param v: variable to check.
:param regex: regular expression to check against (can be either a string, or compiled regexp).
"""
m = re.match(regex, v)
if m is None:
vn = _retrieve... |
Assert that variable satisfies the provided condition. | def assert_satisfies(v, cond, message=None):
"""
Assert that variable satisfies the provided condition.
:param v: variable to check. Its value is only used for error reporting.
:param bool cond: condition that must be satisfied. Should be somehow related to the variable ``v``.
:param message: messa... |
Magic variable name retrieval. | def _retrieve_assert_arguments():
"""
Magic variable name retrieval.
This function is designed as a helper for assert_is_type() function. Typically such assertion is used like this::
assert_is_type(num_threads, int)
If the variable `num_threads` turns out to be non-integer, we would like to r... |
Return True if the variable is of the specified type and False otherwise. | def _check_type(var, vtype):
"""
Return True if the variable is of the specified type, and False otherwise.
:param var: variable to check
:param vtype: expected variable's type
"""
if vtype is None:
return var is None
if isinstance(vtype, _primitive_type):
return var == vtyp... |
Return the name of the provided type. | def _get_type_name(vtype, dump=None):
"""
Return the name of the provided type.
_get_type_name(int) == "integer"
_get_type_name(str) == "string"
_get_type_name(tuple) == "tuple"
_get_type_name(Exception) == "Exception"
_get_type_name(U(int, float, bool)) == "integer|floa... |
Attempt to find the source code of the lambda_fn within the string src. | def _get_lambda_source_code(lambda_fn, src):
"""Attempt to find the source code of the ``lambda_fn`` within the string ``src``."""
def gen_lambdas():
def gen():
yield src + "\n"
g = gen()
step = 0
tokens = []
for tok in tokenize.generate_tokens(getattr(g, "ne... |
Return string representing the name of this type. | def name(self, src=None):
"""Return string representing the name of this type."""
res = [_get_type_name(tt, src) for tt in self._types]
if len(res) == 2 and "None" in res:
res.remove("None")
return "?" + res[0]
else:
return " | ".join(res) |
Return True if the variable matches this type and False otherwise. | def check(self, var):
"""Return True if the variable matches this type, and False otherwise."""
return all(_check_type(var, tt) for tt in self._types) |
Return string representing the name of this type. | def name(self, src=None):
"""Return string representing the name of this type."""
return " & ".join(_get_type_name(tt, src) for tt in self._types) |
Return True if the variable does not match any of the types and False otherwise. | def check(self, var):
"""Return True if the variable does not match any of the types, and False otherwise."""
return not any(_check_type(var, tt) for tt in self._types) |
Return string representing the name of this type. | def name(self, src=None):
"""Return string representing the name of this type."""
if len(self._types) > 1:
return "!(%s)" % str("|".join(_get_type_name(tt, src) for tt in self._types))
else:
return "!" + _get_type_name(self._types[0], src) |
Return True if the variable matches this type and False otherwise. | def check(self, var):
"""Return True if the variable matches this type, and False otherwise."""
return isinstance(var, tuple) and all(_check_type(t, self._element_type) for t in var) |
Return True if the variable matches this type and False otherwise. | def check(self, var):
"""Return True if the variable matches this type, and False otherwise."""
if not isinstance(var, dict): return False
if any(key not in self._types for key in var): return False
for key, ktype in viewitems(self._types):
val = var.get(key, None)
... |
Return string representing the name of this type. | def name(self, src=None):
"""Return string representing the name of this type."""
return "{%s}" % ", ".join("%s: %s" % (key, _get_type_name(ktype, src))
for key, ktype in viewitems(self._types)) |
Return True if the variable matches the specified type. | def check(self, var):
"""Return True if the variable matches the specified type."""
return (isinstance(var, _int_type) and
(self._lower_bound is None or var >= self._lower_bound) and
(self._upper_bound is None or var <= self._upper_bound)) |
Return string representing the name of this type. | def name(self, src=None):
"""Return string representing the name of this type."""
if self._upper_bound is None and self._lower_bound is None: return "int"
if self._upper_bound is None:
if self._lower_bound == 1: return "int>0"
return "int≥%d" % self._lower_bound
i... |
Return True if the variable matches the specified type. | def check(self, var):
"""Return True if the variable matches the specified type."""
return (isinstance(var, _num_type) and
(self._lower_bound is None or var >= self._lower_bound) and
(self._upper_bound is None or var <= self._upper_bound)) |
Return True if the variable matches this type and False otherwise. | def check(self, var):
"""Return True if the variable matches this type, and False otherwise."""
if self._class is None: self._init()
return self._class and self._checker(var, self._class) |
Check whether the provided value is a valid enum constant. | def check(self, var):
"""Check whether the provided value is a valid enum constant."""
if not isinstance(var, _str_type): return False
return _enum_mangle(var) in self._consts |
Retrieve the config as a dictionary of key - value pairs. | def get_config():
"""Retrieve the config as a dictionary of key-value pairs."""
self = H2OConfigReader._get_instance()
if not self._config_loaded:
self._read_config()
return self._config |
Find and parse config file storing all variables in self. _config. | def _read_config(self):
"""Find and parse config file, storing all variables in ``self._config``."""
self._config_loaded = True
conf = []
for f in self._candidate_log_files():
if os.path.isfile(f):
self._logger.info("Reading config file %s" % f)
... |
Return possible locations for the. h2oconfig file one at a time. | def _candidate_log_files():
"""Return possible locations for the .h2oconfig file, one at a time."""
# Search for .h2oconfig in the current directory and all parent directories
relpath = ".h2oconfig"
prevpath = None
while True:
abspath = os.path.abspath(relpath)
... |
Start the progress bar and return only when the progress reaches 100%. | def execute(self, progress_fn, print_verbose_info=None):
"""
Start the progress bar, and return only when the progress reaches 100%.
:param progress_fn: the executor function (or a generator). This function should take no arguments
and return either a single number -- the current pr... |
Save the current model progress into self. _progress_data and update self. _next_poll_time. | def _store_model_progress(self, res, now):
"""
Save the current model progress into ``self._progress_data``, and update ``self._next_poll_time``.
:param res: tuple (progress level, poll delay).
:param now: current timestamp.
"""
raw_progress, delay = res
raw_prog... |
Compute t0 x0 v0 ve. | def _recalculate_model_parameters(self, now):
"""Compute t0, x0, v0, ve."""
time_until_end = self._estimate_progress_completion_time(now) - now
assert time_until_end >= 0, "Estimated progress completion cannot be in the past."
x_real = self._get_real_progress()
if x_real == 1:
... |
Estimate the moment when the underlying process is expected to reach completion. | def _estimate_progress_completion_time(self, now):
"""
Estimate the moment when the underlying process is expected to reach completion.
This function should only return future times. Also this function is not allowed to return time moments less
than self._next_poll_time if the actual pr... |
Determine when to query the progress status next. | def _guess_next_poll_interval(self):
"""
Determine when to query the progress status next.
This function is used if the external progress function did not return time interval for when it should be
queried next.
"""
time_elapsed = self._progress_data[-1][0] - self._progr... |
Calculate the modelled progress state for the given time moment. | def _compute_progress_at_time(self, t):
"""
Calculate the modelled progress state for the given time moment.
:returns: tuple (x, v) of the progress level and progress speed.
"""
t0, x0, v0, ve = self._t0, self._x0, self._v0, self._ve
z = (v0 - ve) * math.exp(-self.BETA *... |
Return the projected time when progress level x_target will be reached. | def _get_time_at_progress(self, x_target):
"""
Return the projected time when progress level `x_target` will be reached.
Since the underlying progress model is nonlinear, we need to do use Newton method to find a numerical solution
to the equation x(t) = x_target.
"""
t,... |
Print the rendered string to the stdout. | def _draw(self, txt, final=False):
"""Print the rendered string to the stdout."""
if not self._file_mode:
# If the user presses Ctrl+C this ensures we still start writing from the beginning of the line
sys.stdout.write("\r")
sys.stdout.write(txt)
if final and not ... |
Render the widget. | def render(self, progress, width=None, status=None):
"""Render the widget."""
results = [widget.render(progress, width=self._widget_lengths[i], status=status)
for i, widget in enumerate(self._widgets)]
if self._file_mode:
res = ""
for i, result in enum... |
Initial rendering stage done in order to compute widths of all widgets. | def _compute_widget_sizes(self):
"""Initial rendering stage, done in order to compute widths of all widgets."""
wl = [0] * len(self._widgets)
flex_count = 0
# First render all non-flexible widgets
for i, widget in enumerate(self._widgets):
if isinstance(widget, Progr... |
Find current STDOUT s width in characters. | def _get_terminal_size():
"""Find current STDOUT's width, in characters."""
# If output is not terminal but a regular file, assume 100 chars width
if not sys.stdout.isatty():
return 80
# Otherwise, first try getting the dimensions from shell command `stty`:
try:
... |
Render the widget. | def render(self, progress, width=None, status=None):
"""Render the widget."""
if width <= 3: return RenderResult()
bar_width = width - 2 # Total width minus the bar ends
n_chars = int(progress * bar_width + 0.001)
endf, endl = self._bar_ends
if self._file_mode:
... |
Inform the widget about the encoding of the underlying character stream. | def set_encoding(self, encoding):
"""Inform the widget about the encoding of the underlying character stream."""
self._bar_ends = "[]"
self._bar_symbols = "#"
if not encoding: return
s1 = "\u258F\u258E\u258D\u258C\u258B\u258A\u2589\u2588"
s2 = "\u258C\u2588"
s3 = ... |
Render the widget. | def render(self, progress, width=None, status=None):
"""Render the widget."""
current_pct = int(progress * 100 + 0.1)
return RenderResult(rendered="%3d%%" % current_pct, next_progress=(current_pct + 1) / 100) |
This function will generate an H2OFrame of two columns. One column will be float and the other will be long.: param sizeMat: integer denoting size of bounds: param lowBound: lower bound: param uppderBound:: param trueRandom:: param numRep: number of times to repeat arrays in order to generate duplicated rows: param num... | def genDataFrame(sizeMat, lowBound, uppderBound, numRep, numZeros, numNans, numInfs):
'''
This function will generate an H2OFrame of two columns. One column will be float and the other will
be long.
:param sizeMat: integer denoting size of bounds
:param lowBound: lower bound
:param uppderB... |
Returns encoding map as an object that maps column_name - > frame_with_encoding_map_for_this_column_name | def fit(self, frame = None):
"""
Returns encoding map as an object that maps 'column_name' -> 'frame_with_encoding_map_for_this_column_name'
:param frame frame: An H2OFrame object with which to create the target encoding map
"""
self._teColumns = list(map(lambda i: frame.names[i... |
Apply transformation to te_columns based on the encoding maps generated during TargetEncoder. fit () call. You must not pass encodings manually from. fit () method because they are being stored internally after. fit () had been called. | def transform(self, frame=None, holdout_type=None, noise=-1, seed=-1):
"""
Apply transformation to `te_columns` based on the encoding maps generated during `TargetEncoder.fit()` call.
You must not pass encodings manually from `.fit()` method because they are being stored internally
after... |
For an H2O Enum column we perform one - hot - encoding here and add one more column missing ( NA ) to it. | def generatePandaEnumCols(pandaFtrain, cname, nrows, domainL):
"""
For an H2O Enum column, we perform one-hot-encoding here and add one more column, "missing(NA)" to it.
:param pandaFtrain: panda frame derived from H2OFrame
:param cname: column name of enum col
:param nrows: number of rows of enum ... |
Retrieve an existing H2OFrame from the H2O cluster using the frame s id. | def get_frame(frame_id, rows=10, rows_offset=0, cols=-1, full_cols=-1, cols_offset=0, light=False):
"""
Retrieve an existing H2OFrame from the H2O cluster using the frame's id.
:param str frame_id: id of the frame to retrieve
:param int rows: number of rows to fetch for preview (10 by d... |
Reload frame information from the backend H2O server. | def refresh(self):
"""Reload frame information from the backend H2O server."""
self._ex._cache.flush()
self._frame(fill_cache=True) |
The list of column names ( List [ str ] ). | def names(self):
"""The list of column names (List[str])."""
if not self._ex._cache.names_valid():
self._ex._cache.flush()
self._frame(fill_cache=True)
return list(self._ex._cache.names) |
Number of rows in the dataframe ( int ). | def nrows(self):
"""Number of rows in the dataframe (int)."""
if not self._ex._cache.nrows_valid():
self._ex._cache.flush()
self._frame(fill_cache=True)
return self._ex._cache.nrows |
Number of columns in the dataframe ( int ). | def ncols(self):
"""Number of columns in the dataframe (int)."""
if not self._ex._cache.ncols_valid():
self._ex._cache.flush()
self._frame(fill_cache=True)
return self._ex._cache.ncols |
The dictionary of column name/ type pairs. | def types(self):
"""The dictionary of column name/type pairs."""
if not self._ex._cache.types_valid():
self._ex._cache.flush()
self._frame(fill_cache=True)
return dict(self._ex._cache.types) |
The type for the given column. | def type(self, col):
"""
The type for the given column.
:param col: either a name, or an index of the column to look up
:returns: type of the column, one of: ``str``, ``int``, ``real``, ``enum``, ``time``, ``bool``.
:raises H2OValueError: if such column does not exist in the fra... |
Extract columns of the specified type from the frame. | def columns_by_type(self, coltype="numeric"):
"""
Extract columns of the specified type from the frame.
:param str coltype: A character string indicating which column type to filter by. This must be
one of the following:
- ``"numeric"`` - Numeric, but not categoric... |
Used by the H2OFrame. __repr__ method to print or display a snippet of the data frame. | def show(self, use_pandas=False, rows=10, cols=200):
"""
Used by the H2OFrame.__repr__ method to print or display a snippet of the data frame.
If called from IPython, displays an html'ized result. Else prints a tabulate'd result.
"""
if self._ex is None:
print("This ... |
Display summary information about the frame. | def summary(self, return_data=False):
"""
Display summary information about the frame.
Summary includes min/mean/max/sigma and other rollup data.
:param bool return_data: Return a dictionary of the summary output
"""
if not self._has_content():
print("This H... |
Generate an in - depth description of this H2OFrame. | def describe(self, chunk_summary=False):
"""
Generate an in-depth description of this H2OFrame.
This will print to the console the dimensions of the frame; names/types/summary statistics for each column;
and finally first ten rows of the frame.
:param bool chunk_summary: Retrie... |
Return the first rows and cols of the frame as a new H2OFrame. | def head(self, rows=10, cols=200):
"""
Return the first ``rows`` and ``cols`` of the frame as a new H2OFrame.
:param int rows: maximum number of rows to return
:param int cols: maximum number of columns to return
:returns: a new H2OFrame cut from the top left corner of the curre... |
Multiply this frame viewed as a matrix by another matrix. | def mult(self, matrix):
"""
Multiply this frame, viewed as a matrix, by another matrix.
:param matrix: another frame that you want to multiply the current frame by; must be compatible with the
current frame (i.e. its number of rows must be the same as number of columns in the curren... |
Create a time column from individual components. | def moment(year=None, month=None, day=None, hour=None, minute=None, second=None, msec=None, date=None, time=None):
"""
Create a time column from individual components.
Each parameter should be either an integer, or a single-column H2OFrame
containing the corresponding time parts for eac... |
Get the factor levels. | def levels(self):
"""
Get the factor levels.
:returns: A list of lists, one list per column, of levels.
"""
lol = H2OFrame._expr(expr=ExprNode("levels", self)).as_data_frame(False)
lol.pop(0) # Remove column headers
lol = list(zip(*lol))
return [[ll for ... |
Get the number of factor levels for each categorical column. | def nlevels(self):
"""
Get the number of factor levels for each categorical column.
:returns: A list of the number of levels per column.
"""
levels = self.levels()
return [len(l) for l in levels] if levels else 0 |
A method to set all column values to one of the levels. | def set_level(self, level):
"""
A method to set all column values to one of the levels.
:param str level: The level at which the column will be set (a string)
:returns: H2OFrame with entries set to the desired level.
"""
return H2OFrame._expr(expr=ExprNode("setLevel", s... |
Replace the levels of a categorical column. | def set_levels(self, levels):
"""
Replace the levels of a categorical column.
New levels must be aligned with the old domain. This call has copy-on-write semantics.
:param List[str] levels: A list of strings specifying the new levels. The number of new
levels must match the... |
Change names of columns in the frame. | def rename(self, columns=None):
"""
Change names of columns in the frame.
Dict key is an index or name of the column whose name is to be set.
Dict value is the new name of the column.
:param columns: dict-like transformations to apply to the column names
"""
ass... |
Change names of all columns in the frame. | def set_names(self, names):
"""
Change names of all columns in the frame.
:param List[str] names: The list of new names for every column in the frame.
"""
assert_is_type(names, [str])
assert_satisfies(names, len(names) == self.ncol)
self._ex = ExprNode("colnames=... |
Set a new name for a column. | def set_name(self, col=None, name=None):
"""
Set a new name for a column.
:param col: index or name of the column whose name is to be set; may be skipped for 1-column frames
:param name: the new name of the column
"""
assert_is_type(col, None, int, str)
assert_is... |
Compute cumulative sum over rows/ columns of the frame. | def cumsum(self, axis=0):
"""
Compute cumulative sum over rows / columns of the frame.
:param int axis: 0 for column-wise, 1 for row-wise
:returns: new H2OFrame with cumulative sums of the original frame.
"""
return H2OFrame._expr(expr=ExprNode("cumsum", self, axis), ca... |
Test whether elements of an H2OFrame are contained in the item. | def isin(self, item):
"""
Test whether elements of an H2OFrame are contained in the ``item``.
:param items: An item or a list of items to compare the H2OFrame against.
:returns: An H2OFrame of 0s and 1s showing whether each element in the original H2OFrame is contained in item.
... |
Build a fold assignments column for cross - validation. | def modulo_kfold_column(self, n_folds=3):
"""
Build a fold assignments column for cross-validation.
Rows are assigned a fold according to the current row number modulo ``n_folds``.
:param int n_folds: An integer specifying the number of validation sets to split the training data into.
... |
Build a fold assignment column with the constraint that each fold has the same class distribution as the fold column. | def stratified_kfold_column(self, n_folds=3, seed=-1):
"""
Build a fold assignment column with the constraint that each fold has the same class
distribution as the fold column.
:param int n_folds: The number of folds to build.
:param int seed: A seed for the random number genera... |
Compactly display the internal structure of an H2OFrame. | def structure(self):
"""Compactly display the internal structure of an H2OFrame."""
df = self.as_data_frame(use_pandas=False)
cn = df.pop(0)
nr = self.nrow
nc = self.ncol
width = max([len(c) for c in cn])
isfactor = self.isfactor()
numlevels = self.nlevels... |
Obtain the dataset as a python - local object. | def as_data_frame(self, use_pandas=True, header=True):
"""
Obtain the dataset as a python-local object.
:param bool use_pandas: If True (default) then return the H2OFrame as a pandas DataFrame (requires that the
``pandas`` library was installed). If False, then return the contents o... |
Drop a single column or row or a set of columns or rows from a H2OFrame. | def drop(self, index, axis=1):
"""
Drop a single column or row or a set of columns or rows from a H2OFrame.
Dropping a column or row is not in-place.
Indices of rows and columns are zero-based.
:param index: A list of column indices, column names, or row indices to drop; or
... |
Pop a column from the H2OFrame at index i. | def pop(self, i):
"""
Pop a column from the H2OFrame at index i.
:param i: The index (int) or name (str) of the column to pop.
:returns: an H2OFrame containing the column dropped from the current frame; the current frame is modified
in-place and loses the column.
"""... |
Compute quantiles. | def quantile(self, prob=None, combine_method="interpolate", weights_column=None):
"""
Compute quantiles.
:param List[float] prob: list of probabilities for which quantiles should be computed.
:param str combine_method: for even samples this setting determines how to combine quantiles. T... |
Append multiple H2OFrames to this frame column - wise or row - wise. | def concat(self, frames, axis=1):
"""
Append multiple H2OFrames to this frame, column-wise or row-wise.
:param List[H2OFrame] frames: list of frames that should be appended to the current frame.
:param int axis: if 1 then append column-wise (default), if 0 then append row-wise.
... |
Append data to this frame column - wise. | def cbind(self, data):
"""
Append data to this frame column-wise.
:param H2OFrame data: append columns of frame ``data`` to the current frame. You can also cbind a number,
in which case it will get converted into a constant column.
:returns: new H2OFrame with all frames in ... |
Append data to this frame row - wise. | def rbind(self, data):
"""
Append data to this frame row-wise.
:param data: an H2OFrame or a list of H2OFrame's to be combined with current frame row-wise.
:returns: this H2OFrame with all frames in data appended row-wise.
"""
assert_is_type(data, H2OFrame, [H2OFrame])
... |
Split a frame into distinct subsets of size determined by the given ratios. | def split_frame(self, ratios=None, destination_frames=None, seed=None):
"""
Split a frame into distinct subsets of size determined by the given ratios.
The number of subsets is always 1 more than the number of ratios given. Note that
this does not give an exact split. H2O is designed to... |
Return a new GroupBy object using this frame and the desired grouping columns. | def group_by(self, by):
"""
Return a new ``GroupBy`` object using this frame and the desired grouping columns.
The returned groups are sorted by the natural group-by column sort.
:param by: The columns to group on (either a single column name, or a list of column names, or
... |
Return a new Frame that is sorted by column ( s ) in ascending order. A fully distributed and parallel sort. However the original frame can contain String columns but sorting cannot be done on String columns. Default sorting direction is ascending. | def sort(self, by, ascending=[]):
"""
Return a new Frame that is sorted by column(s) in ascending order. A fully distributed and parallel sort.
However, the original frame can contain String columns but sorting cannot be done on String columns.
Default sorting direction is ascending.
... |
Return a new Frame that fills NA along a given axis and along a given direction with a maximum fill length | def fillna(self,method="forward",axis=0,maxlen=1):
"""
Return a new Frame that fills NA along a given axis and along a given direction with a maximum fill length
:param method: ``"forward"`` or ``"backward"``
:param axis: 0 for columnar-wise or 1 for row-wise fill
:param maxlen... |
Impute missing values into the frame modifying it in - place. | def impute(self, column=-1, method="mean", combine_method="interpolate", by=None, group_by_frame=None, values=None):
"""
Impute missing values into the frame, modifying it in-place.
:param int column: Index of the column to impute, or -1 to impute the entire frame.
:param str method: Th... |
Merge two datasets based on common column names. We do not support all_x = True and all_y = True. Only one can be True or none is True. The default merge method is auto and it will default to the radix method. The radix method will return the correct merge result regardless of duplicated rows in the right frame. In add... | def merge(self, other, all_x=False, all_y=False, by_x=None, by_y=None, method="auto"):
"""
Merge two datasets based on common column names. We do not support all_x=True and all_y=True.
Only one can be True or none is True. The default merge method is auto and it will default to the
rad... |
Reorder levels of an H2O factor for one single column of a H2O frame | def relevel(self, y):
"""
Reorder levels of an H2O factor for one single column of a H2O frame
The levels of a factor are reordered such that the reference level is at level 0, all remaining levels are
moved down as needed.
:param str y: The reference level
:returns: Ne... |
Insert missing values into the current frame modifying it in - place. | def insert_missing_values(self, fraction=0.1, seed=None):
"""
Insert missing values into the current frame, modifying it in-place.
Randomly replaces a user-specified fraction of entries in a H2O dataset with missing
values.
:param float fraction: A number between 0 and 1 indica... |
Compute the frame s sum by - column ( or by - row ). | def sum(self, skipna=True, axis=0, **kwargs):
"""
Compute the frame's sum by-column (or by-row).
:param bool skipna: If True (default), then NAs are ignored during the computation. Otherwise presence
of NAs renders the entire result NA.
:param int axis: Direction of sum comp... |
Compute the variance - covariance matrix of one or two H2OFrames. | def var(self, y=None, na_rm=False, use=None):
"""
Compute the variance-covariance matrix of one or two H2OFrames.
:param H2OFrame y: If this parameter is given, then a covariance matrix between the columns of the target
frame and the columns of ``y`` is computed. If this parameter ... |
Compute the correlation matrix of one or two H2OFrames. | def cor(self, y=None, na_rm=False, use=None):
"""
Compute the correlation matrix of one or two H2OFrames.
:param H2OFrame y: If this parameter is provided, then compute correlation between the columns of ``y``
and the columns of the current frame. If this parameter is not given, the... |
Compute a pairwise distance measure between all rows of two numeric H2OFrames. | def distance(self, y, measure=None):
"""
Compute a pairwise distance measure between all rows of two numeric H2OFrames.
:param H2OFrame y: Frame containing queries (small)
:param str use: A string indicating what distance measure to use. Must be one of:
- ``"l1"``: A... |
Compute element - wise string distances between two H2OFrames. Both frames need to have the same shape and only contain string/ factor columns. | def strdistance(self, y, measure=None, compare_empty=True):
"""
Compute element-wise string distances between two H2OFrames. Both frames need to have the same
shape and only contain string/factor columns.
:param H2OFrame y: A comparison frame.
:param str measure: A string identi... |
Convert columns in the current frame to categoricals. | def asfactor(self):
"""
Convert columns in the current frame to categoricals.
:returns: new H2OFrame with columns of the "enum" type.
"""
for colname in self.names:
t = self.types[colname]
if t not in {"bool", "int", "string", "enum"}:
rai... |
Return the list of levels for an enum ( categorical ) column. | def categories(self):
"""
Return the list of levels for an enum (categorical) column.
This function can only be applied to single-column categorical frame.
"""
if self.ncols != 1:
raise H2OValueError("This operation only applies to a single factor column")
if... |
Split the strings in the target column on the given regular expression pattern. | def strsplit(self, pattern):
"""
Split the strings in the target column on the given regular expression pattern.
:param str pattern: The split pattern.
:returns: H2OFrame containing columns of the split strings.
"""
fr = H2OFrame._expr(expr=ExprNode("strsplit", self, pat... |
Tokenize String | def tokenize(self, split):
"""
Tokenize String
tokenize() is similar to strsplit(), the difference between them is that tokenize() will store the tokenized
text into a single column making it easier for additional processing (filtering stop words, word2vec algo, ...).
:param st... |
For each string in the frame count the occurrences of the provided pattern. If countmathces is applied to a frame all columns of the frame must be type string otherwise the returned frame will contain errors. | def countmatches(self, pattern):
"""
For each string in the frame, count the occurrences of the provided pattern. If countmathces is applied to
a frame, all columns of the frame must be type string, otherwise, the returned frame will contain errors.
The pattern here is a plain string, ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.