_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 75 19.8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q267200 | download_pojo | test | def download_pojo(model, path="", get_jar=True, jar_name=""):
"""
Download the POJO for this model to the directory specified by path; if path is "", then dump to screen.
:param model: the model whose scoring POJO should be retrieved.
:param path: an absolute path to the directory where POJO should be ... | python | {
"resource": ""
} |
q267201 | download_csv | test | def download_csv(data, filename):
"""
Download an H2O data set to a CSV file on the local disk.
Warning: Files located on the H2O server may be very large! Make sure you have enough
hard drive space to accommodate the entire file.
:param data: an H2OFrame object to be downloaded.
:param filena... | python | {
"resource": ""
} |
q267202 | download_all_logs | test | def download_all_logs(dirname=".", filename=None):
"""
Download H2O log files to disk.
:param dirname: a character string indicating the directory that the log file should be saved in.
:param filename: a string indicating the name that the CSV file should be. Note that the saved format is .zip, so the ... | python | {
"resource": ""
} |
q267203 | export_file | test | def export_file(frame, path, force=False, parts=1):
"""
Export a given H2OFrame to a path on the machine this python session is currently connected to.
:param frame: the Frame to save to disk.
:param path: the path to the save point on disk.
:param force: if True, overwrite any preexisting file wit... | python | {
"resource": ""
} |
q267204 | as_list | test | def as_list(data, use_pandas=True, header=True):
"""
Convert an H2O data object into a python-specific object.
WARNING! This will pull all data local!
If Pandas is available (and use_pandas is True), then pandas will be used to parse the
data frame. Otherwise, a list-of-lists populated by characte... | python | {
"resource": ""
} |
q267205 | demo | test | def demo(funcname, interactive=True, echo=True, test=False):
"""
H2O built-in demo facility.
:param funcname: A string that identifies the h2o python function to demonstrate.
:param interactive: If True, the user will be prompted to continue the demonstration after every segment.
:param echo: If Tr... | python | {
"resource": ""
} |
q267206 | load_dataset | test | def load_dataset(relative_path):
"""Imports a data file within the 'h2o_data' folder."""
assert_is_type(relative_path, str)
h2o_dir = os.path.split(__file__)[0]
for possible_file in [os.path.join(h2o_dir, relative_path),
os.path.join(h2o_dir, "h2o_data", relative_path),
... | python | {
"resource": ""
} |
q267207 | make_metrics | test | def make_metrics(predicted, actual, domain=None, distribution=None):
"""
Create Model Metrics from predicted and actual values in H2O.
:param H2OFrame predicted: an H2OFrame containing predictions.
:param H2OFrame actuals: an H2OFrame containing actual values.
:param domain: list of response factor... | python | {
"resource": ""
} |
q267208 | _put_key | test | def _put_key(file_path, dest_key=None, overwrite=True):
"""
Upload given file into DKV and save it under give key as raw object.
:param dest_key: name of destination key in DKV
:param file_path: path to file to upload
:return: key name if object was uploaded successfully
"""
ret = api("PO... | python | {
"resource": ""
} |
q267209 | upload_custom_metric | test | def upload_custom_metric(func, func_file="metrics.py", func_name=None, class_name=None, source_provider=None):
"""
Upload given metrics function into H2O cluster.
The metrics can have different representation:
- class: needs to implement map(pred, act, weight, offset, model), reduce(l, r) and metric(... | python | {
"resource": ""
} |
q267210 | check_frame_id | test | def check_frame_id(frame_id):
"""Check that the provided frame id is valid in Rapids language."""
if frame_id is None:
return
if frame_id.strip() == "":
raise H2OValueError("Frame id cannot be an empty string: %r" % frame_id)
for i, ch in enumerate(frame_id):
# '$' character has ... | python | {
"resource": ""
} |
q267211 | get_human_readable_bytes | test | def get_human_readable_bytes(size):
"""
Convert given number of bytes into a human readable representation, i.e. add prefix such as kb, Mb, Gb,
etc. The `size` argument must be a non-negative integer.
:param size: integer representing byte size of something
:return: string representation of the siz... | python | {
"resource": ""
} |
q267212 | normalize_slice | test | def normalize_slice(s, total):
"""
Return a "canonical" version of slice ``s``.
:param slice s: the original slice expression
:param total int: total number of elements in the collection sliced by ``s``
:return slice: a slice equivalent to ``s`` but not containing any negative indices or Nones.
... | python | {
"resource": ""
} |
q267213 | slice_is_normalized | test | def slice_is_normalized(s):
"""Return True if slice ``s`` in "normalized" form."""
return (s.start is not None and s.stop is not None and s.step is not None and s.start <= s.stop) | python | {
"resource": ""
} |
q267214 | mojo_predict_pandas | test | def mojo_predict_pandas(dataframe, mojo_zip_path, genmodel_jar_path=None, classpath=None, java_options=None, verbose=False):
"""
MOJO scoring function to take a Pandas frame and use MOJO model as zip file to score.
:param dataframe: Pandas frame to score.
:param mojo_zip_path: Path to MOJO zip download... | python | {
"resource": ""
} |
q267215 | mojo_predict_csv | test | def mojo_predict_csv(input_csv_path, mojo_zip_path, output_csv_path=None, genmodel_jar_path=None, classpath=None, java_options=None, verbose=False):
"""
MOJO scoring function to take a CSV file and use MOJO model as zip file to score.
:param input_csv_path: Path to input CSV file.
:param mojo_zip_path:... | python | {
"resource": ""
} |
q267216 | deprecated | test | def deprecated(message):
"""The decorator to mark deprecated functions."""
from traceback import extract_stack
assert message, "`message` argument in @deprecated is required."
def deprecated_decorator(fun):
def decorator_invisible(*args, **kwargs):
stack = extract_stack()
... | python | {
"resource": ""
} |
q267217 | H2OGridSearch.join | test | def join(self):
"""Wait until grid finishes computing."""
self._future = False
self._job.poll()
self._job = None | python | {
"resource": ""
} |
q267218 | H2OGridSearch.deepfeatures | test | def deepfeatures(self, test_data, layer):
"""
Obtain a hidden layer's details on a dataset.
:param test_data: Data to create a feature space on.
:param int layer: Index of the hidden layer.
:returns: A dictionary of hidden layer details for each model.
"""
return... | python | {
"resource": ""
} |
q267219 | H2OGridSearch.summary | test | def summary(self, header=True):
"""Print a detailed summary of the explored models."""
table = []
for model in self.models:
model_summary = model._model_json["output"]["model_summary"]
r_values = list(model_summary.cell_values[0])
r_values[0] = model.model_id
... | python | {
"resource": ""
} |
q267220 | H2OGridSearch.show | test | def show(self):
"""Print models sorted by metric."""
hyper_combos = itertools.product(*list(self.hyper_params.values()))
if not self.models:
c_values = [[idx + 1, list(val)] for idx, val in enumerate(hyper_combos)]
print(H2OTwoDimTable(
col_header=['Model'... | python | {
"resource": ""
} |
q267221 | H2OGridSearch.get_hyperparams | test | def get_hyperparams(self, id, display=True):
"""
Get the hyperparameters of a model explored by grid search.
:param str id: The model id of the model with hyperparameters of interest.
:param bool display: Flag to indicate whether to display the hyperparameter names.
:returns: A... | python | {
"resource": ""
} |
q267222 | H2OGridSearch.get_hyperparams_dict | test | def get_hyperparams_dict(self, id, display=True):
"""
Derived and returned the model parameters used to train the particular grid search model.
:param str id: The model id of the model with hyperparameters of interest.
:param bool display: Flag to indicate whether to display the hyperpa... | python | {
"resource": ""
} |
q267223 | H2OGridSearch.get_grid | test | def get_grid(self, sort_by=None, decreasing=None):
"""
Retrieve an H2OGridSearch instance.
Optionally specify a metric by which to sort models and a sort order.
Note that if neither cross-validation nor a validation frame is used in the grid search, then the
training metrics wil... | python | {
"resource": ""
} |
q267224 | H2OBinomialGridSearch.F1 | test | def F1(self, thresholds=None, train=False, valid=False, xval=False):
"""
Get the F1 values for a set of thresholds for the models explored.
If all are False (default), then return the training metric value.
If more than one options is set to True, then return a dictionary of metrics whe... | python | {
"resource": ""
} |
q267225 | H2ODimReductionModel.varimp | test | def varimp(self, use_pandas=False):
"""
Return the Importance of components associcated with a pca model.
use_pandas: ``bool`` (default: ``False``).
"""
model = self._model_json["output"]
if "importance" in list(model.keys()) and model["importance"]:
vals = ... | python | {
"resource": ""
} |
q267226 | H2ODimReductionModel.proj_archetypes | test | def proj_archetypes(self, test_data, reverse_transform=False):
"""
Convert archetypes of the model into original feature space.
:param H2OFrame test_data: The dataset upon which the model was trained.
:param bool reverse_transform: Whether the transformation of the training data during ... | python | {
"resource": ""
} |
q267227 | H2ODimReductionModel.screeplot | test | def screeplot(self, type="barplot", **kwargs):
"""
Produce the scree plot.
Library ``matplotlib`` is required for this function.
:param str type: either ``"barplot"`` or ``"lines"``.
"""
# check for matplotlib. exit if absent.
is_server = kwargs.pop("server")
... | python | {
"resource": ""
} |
q267228 | translate_name | test | def translate_name(name):
"""
Convert names with underscores into camelcase.
For example:
"num_rows" => "numRows"
"very_long_json_name" => "veryLongJsonName"
"build_GBM_model" => "buildGbmModel"
"KEY" => "key"
"middle___underscores" => "middleUnderscores"
"_e... | python | {
"resource": ""
} |
q267229 | dedent | test | def dedent(ind, text):
"""
Dedent text to the specific indentation level.
:param ind: common indentation level for the resulting text (number of spaces to append to every line)
:param text: text that should be transformed.
:return: ``text`` with all common indentation removed, and then the specifie... | python | {
"resource": ""
} |
q267230 | extractRunInto | test | def extractRunInto(javaLogText):
"""
This function will extract the various operation time for GLRM model building iterations.
:param javaLogText:
:return:
"""
global g_initialXY
global g_reguarlize_Y
global g_regularize_X_objective
global g_updateX
global g_updateY
global g... | python | {
"resource": ""
} |
q267231 | main | test | def main(argv):
"""
Main program. Take user input, parse it and call other functions to execute the commands
and extract run summary and store run result in json file
@return: none
"""
global g_test_root_dir
global g_temp_filename
if len(argv) < 2:
print("invoke this script as... | python | {
"resource": ""
} |
q267232 | H2OConnection.close | test | def close(self):
"""
Close an existing connection; once closed it cannot be used again.
Strictly speaking it is not necessary to close all connection that you opened -- we have several mechanisms
in place that will do so automatically (__del__(), __exit__() and atexit() handlers), howev... | python | {
"resource": ""
} |
q267233 | H2OConnection.session_id | test | def session_id(self):
"""
Return the session id of the current connection.
The session id is issued (through an API request) the first time it is requested, but no sooner. This is
because generating a session id puts it into the DKV on the server, which effectively locks the cluster. On... | python | {
"resource": ""
} |
q267234 | H2OConnection.start_logging | test | def start_logging(self, dest=None):
"""
Start logging all API requests to the provided destination.
:param dest: Where to write the log: either a filename (str), or an open file handle (file). If not given,
then a new temporary file will be created.
"""
assert_is_typ... | python | {
"resource": ""
} |
q267235 | H2OConnection._prepare_data_payload | test | def _prepare_data_payload(data):
"""
Make a copy of the `data` object, preparing it to be sent to the server.
The data will be sent via x-www-form-urlencoded or multipart/form-data mechanisms. Both of them work with
plain lists of key/value pairs, so this method converts the data into s... | python | {
"resource": ""
} |
q267236 | H2OConnection._prepare_file_payload | test | def _prepare_file_payload(filename):
"""
Prepare `filename` to be sent to the server.
The "preparation" consists of creating a data structure suitable
for passing to requests.request().
"""
if not filename: return None
absfilename = os.path.abspath(filename)
... | python | {
"resource": ""
} |
q267237 | H2OConnection._log_start_transaction | test | def _log_start_transaction(self, endpoint, data, json, files, params):
"""Log the beginning of an API request."""
# TODO: add information about the caller, i.e. which module + line of code called the .request() method
# This can be done by fetching current traceback and then traversing it ... | python | {
"resource": ""
} |
q267238 | H2OConnection._log_end_transaction | test | def _log_end_transaction(self, start_time, response):
"""Log response from an API request."""
if not self._is_logging: return
elapsed_time = int((time.time() - start_time) * 1000)
msg = "<<< HTTP %d %s (%d ms)\n" % (response.status_code, response.reason, elapsed_time)
if "Conte... | python | {
"resource": ""
} |
q267239 | H2OConnection._log_message | test | def _log_message(self, msg):
"""
Log the message `msg` to the destination `self._logging_dest`.
If this destination is a file name, then we append the message to the file and then close the file
immediately. If the destination is an open file handle, then we simply write the message the... | python | {
"resource": ""
} |
q267240 | H2OConnection._process_response | test | def _process_response(response, save_to):
"""
Given a response object, prepare it to be handed over to the external caller.
Preparation steps include:
* detect if the response has error status, and convert it to an appropriate exception;
* detect Content-Type, and based on... | python | {
"resource": ""
} |
q267241 | H2OConnection._print | test | def _print(self, msg, flush=False, end="\n"):
"""Helper function to print connection status messages when in verbose mode."""
if self._verbose:
print2(msg, end=end, flush=flush) | python | {
"resource": ""
} |
q267242 | get_automl | test | def get_automl(project_name):
"""
Retrieve information about an AutoML instance.
:param str project_name: A string indicating the project_name of the automl instance to retrieve.
:returns: A dictionary containing the project_name, leader model, and leaderboard.
"""
automl_json = h2o.api("GET /... | python | {
"resource": ""
} |
q267243 | H2OAutoML.download_pojo | test | def download_pojo(self, path="", get_genmodel_jar=False, genmodel_name=""):
"""
Download the POJO for the leader model in AutoML to the directory specified by path.
If path is an empty string, then dump the output to screen.
:param path: An absolute path to the directory where POJO sh... | python | {
"resource": ""
} |
q267244 | H2OAutoML.download_mojo | test | def download_mojo(self, path=".", get_genmodel_jar=False, genmodel_name=""):
"""
Download the leader model in AutoML in MOJO format.
:param path: the path where MOJO file should be saved.
:param get_genmodel_jar: if True, then also download h2o-genmodel.jar and store it in folder ``path... | python | {
"resource": ""
} |
q267245 | H2OScaler.fit | test | def fit(self, X, y=None, **params):
"""
Fit this object by computing the means and standard deviations used by the transform method.
:param X: An H2OFrame; may contain NAs and/or categoricals.
:param y: None (Ignored)
:param params: Ignored
:returns: This H2OScaler insta... | python | {
"resource": ""
} |
q267246 | H2OScaler.transform | test | def transform(self, X, y=None, **params):
"""
Scale an H2OFrame with the fitted means and standard deviations.
:param X: An H2OFrame; may contain NAs and/or categoricals.
:param y: None (Ignored)
:param params: (Ignored)
:returns: A scaled H2OFrame.
"""
r... | python | {
"resource": ""
} |
q267247 | H2OScaler.inverse_transform | test | def inverse_transform(self, X, y=None, **params):
"""
Undo the scale transformation.
:param X: An H2OFrame; may contain NAs and/or categoricals.
:param y: None (Ignored)
:param params: (Ignored)
:returns: An H2OFrame
"""
for i in range(X.ncol):
... | python | {
"resource": ""
} |
q267248 | extract_true_string | test | def extract_true_string(string_content):
"""
remove extra characters before the actual string we are
looking for. The Jenkins console output is encoded using utf-8. However, the stupid
redirect function can only encode using ASCII. I have googled for half a day with no
results to how to resolve t... | python | {
"resource": ""
} |
q267249 | find_node_name | test | def find_node_name(each_line,temp_func_list):
"""
Find the slave machine where a Jenkins job was executed on. It will save this
information in g_failed_test_info_dict. In addition, it will
delete this particular function handle off the temp_func_list as we do not need
to perform this action again.... | python | {
"resource": ""
} |
q267250 | find_git_hash_branch | test | def find_git_hash_branch(each_line,temp_func_list):
"""
Find the git hash and branch info that a Jenkins job was taken from. It will save this
information in g_failed_test_info_dict. In addition, it will delete this particular
function handle off the temp_func_list as we do not need to perform this a... | python | {
"resource": ""
} |
q267251 | find_build_timeout | test | def find_build_timeout(each_line,temp_func_list):
"""
Find if a Jenkins job has taken too long to finish and was killed. It will save this
information in g_failed_test_info_dict.
Parameters
----------
each_line : str
contains a line read in from jenkins console
temp_func_list : ... | python | {
"resource": ""
} |
q267252 | find_build_failure | test | def find_build_failure(each_line,temp_func_list):
"""
Find if a Jenkins job has failed to build. It will save this
information in g_failed_test_info_dict. In addition, it will delete this particular
function handle off the temp_func_list as we do not need to perform this action again.
Parameters
... | python | {
"resource": ""
} |
q267253 | find_build_id | test | def find_build_id(each_line,temp_func_list):
"""
Find the build id of a jenkins job. It will save this
information in g_failed_test_info_dict. In addition, it will delete this particular
function handle off the temp_func_list as we do not need to perform this action again.
Parameters
--------... | python | {
"resource": ""
} |
q267254 | extract_job_build_url | test | def extract_job_build_url(url_string):
"""
From user input, grab the jenkins job name and saved it in g_failed_test_info_dict.
In addition, it will grab the jenkins url and the view name into g_jenkins_url, and
g_view_name.
Parameters
----------
url_string : str
contains informatio... | python | {
"resource": ""
} |
q267255 | grab_java_message | test | def grab_java_message():
"""scan through the java output text and extract the bad java messages that may or may not happened when
unit tests are run. It will not record any bad java messages that are stored in g_ok_java_messages.
:return: none
"""
global g_temp_filename
global g_current_testn... | python | {
"resource": ""
} |
q267256 | save_dict | test | def save_dict():
"""
Save the log scraping results into logs denoted by g_output_filename_failed_tests and
g_output_filename_passed_tests.
:return: none
"""
global g_test_root_dir
global g_output_filename_failed_tests
global g_output_filename_passed_tests
global g_output_pickle_fil... | python | {
"resource": ""
} |
q267257 | update_summary_file | test | def update_summary_file():
"""
Concatecate all log file into a summary text file to be sent to users
at the end of a daily log scraping.
:return: none
"""
global g_summary_text_filename
global g_output_filename_failed_tests
global g_output_filename_passed_tests
with open(g_summary_... | python | {
"resource": ""
} |
q267258 | write_file_content | test | def write_file_content(fhandle,file2read):
"""
Write one log file into the summary text file.
Parameters
----------
fhandle : Python file handle
file handle to the summary text file
file2read : Python file handle
file handle to log file where we want to add its content to the s... | python | {
"resource": ""
} |
q267259 | write_java_message | test | def write_java_message(key,val,text_file):
"""
Loop through all java messages that are not associated with a unit test and
write them into a log file.
Parameters
----------
key : str
9.general_bad_java_messages
val : list of list of str
contains the bad java messages and th... | python | {
"resource": ""
} |
q267260 | load_java_messages_to_ignore | test | def load_java_messages_to_ignore():
"""
Load in pickle file that contains dict structure with bad java messages to ignore per unit test
or for all cases. The ignored bad java info is stored in g_ok_java_messages dict.
:return:
"""
global g_ok_java_messages
global g_java_message_pickle_file... | python | {
"resource": ""
} |
q267261 | normalize_enum_constant | test | def normalize_enum_constant(s):
"""Return enum constant `s` converted to a canonical snake-case."""
if s.islower(): return s
if s.isupper(): return s.lower()
return "".join(ch if ch.islower() else "_" + ch.lower() for ch in s).strip("_") | python | {
"resource": ""
} |
q267262 | H2OWordEmbeddingModel.find_synonyms | test | def find_synonyms(self, word, count=20):
"""
Find synonyms using a word2vec model.
:param str word: A single word to find synonyms for.
:param int count: The first "count" synonyms will be returned.
:returns: the approximate reconstruction of the training data.
"""
... | python | {
"resource": ""
} |
q267263 | H2OJob.poll | test | def poll(self, verbose_model_scoring_history = False):
"""
Wait until the job finishes.
This method will continuously query the server about the status of the job, until the job reaches a
completion. During this time we will display (in stdout) a progress bar with % completion status.
... | python | {
"resource": ""
} |
q267264 | H2OAssembly.to_pojo | test | def to_pojo(self, pojo_name="", path="", get_jar=True):
"""
Convert the munging operations performed on H2OFrame into a POJO.
:param pojo_name: (str) Name of POJO
:param path: (str) path of POJO.
:param get_jar: (bool) Whether to also download the h2o-genmodel.jar file needed ... | python | {
"resource": ""
} |
q267265 | H2OAssembly.fit | test | def fit(self, fr):
"""
To perform the munging operations on a frame specified in steps on the frame fr.
:param fr: H2OFrame where munging operations are to be performed on.
:return: H2OFrame after munging operations are completed.
"""
assert_is_type(fr, H2OFrame)
... | python | {
"resource": ""
} |
q267266 | percentileOnSortedList | test | def percentileOnSortedList(N, percent, key=lambda x:x, interpolate='mean'):
# 5 ways of resolving fractional
# floor, ceil, funky, linear, mean
interpolateChoices = ['floor', 'ceil', 'funky', 'linear', 'mean']
if interpolate not in interpolateChoices:
print "Bad choice for interpolate:", interpo... | python | {
"resource": ""
} |
q267267 | ModelBase.default_params | test | def default_params(self):
"""Dictionary of the default parameters of the model."""
params = {}
for p in self.parms:
params[p] = self.parms[p]["default_value"]
return params | python | {
"resource": ""
} |
q267268 | ModelBase.actual_params | test | def actual_params(self):
"""Dictionary of actual parameters of the model."""
params_to_select = {"model_id": "name",
"response_column": "column_name",
"training_frame": "name",
"validation_frame": "name"}
params ... | python | {
"resource": ""
} |
q267269 | ModelBase.deepfeatures | test | def deepfeatures(self, test_data, layer):
"""
Return hidden layer details.
:param test_data: Data to create a feature space on
:param layer: 0 index hidden layer
"""
if test_data is None: raise ValueError("Must specify test data")
if str(layer).isdigit():
... | python | {
"resource": ""
} |
q267270 | ModelBase.scoring_history | test | def scoring_history(self):
"""
Retrieve Model Score History.
:returns: The score history as an H2OTwoDimTable or a Pandas DataFrame.
"""
model = self._model_json["output"]
if "scoring_history" in model and model["scoring_history"] is not None:
return model["s... | python | {
"resource": ""
} |
q267271 | ModelBase.show | test | def show(self):
"""Print innards of model, without regards to type."""
if self._future:
self._job.poll_once()
return
if self._model_json is None:
print("No model trained yet")
return
if self.model_id is None:
print("This H2OEsti... | python | {
"resource": ""
} |
q267272 | ModelBase.varimp | test | def varimp(self, use_pandas=False):
"""
Pretty print the variable importances, or return them in a list.
:param use_pandas: If True, then the variable importances will be returned as a pandas data frame.
:returns: A list or Pandas DataFrame.
"""
model = self._model_json... | python | {
"resource": ""
} |
q267273 | ModelBase.residual_degrees_of_freedom | test | def residual_degrees_of_freedom(self, train=False, valid=False, xval=False):
"""
Retreive the residual degress of freedom if this model has the attribute, or None otherwise.
:param bool train: Get the residual dof for the training set. If both train and valid are False, then train
i... | python | {
"resource": ""
} |
q267274 | ModelBase.coef | test | def coef(self):
"""
Return the coefficients which can be applied to the non-standardized data.
Note: standardize = True by default, if set to False then coef() return the coefficients which are fit directly.
"""
tbl = self._model_json["output"]["coefficients_table"]
if t... | python | {
"resource": ""
} |
q267275 | ModelBase.download_pojo | test | def download_pojo(self, path="", get_genmodel_jar=False, genmodel_name=""):
"""
Download the POJO for this model to the directory specified by path.
If path is an empty string, then dump the output to screen.
:param path: An absolute path to the directory where POJO should be saved.
... | python | {
"resource": ""
} |
q267276 | ModelBase.download_mojo | test | def download_mojo(self, path=".", get_genmodel_jar=False, genmodel_name=""):
"""
Download the model in MOJO format.
:param path: the path where MOJO file should be saved.
:param get_genmodel_jar: if True, then also download h2o-genmodel.jar and store it in folder ``path``.
:para... | python | {
"resource": ""
} |
q267277 | ModelBase.save_model_details | test | def save_model_details(self, path="", force=False):
"""
Save Model Details of an H2O Model in JSON Format to disk.
:param model: The model object to save.
:param path: a path to save the model details at (hdfs, s3, local)
:param force: if True overwrite destination directory in ... | python | {
"resource": ""
} |
q267278 | ModelBase._check_targets | test | def _check_targets(y_actual, y_predicted):
"""Check that y_actual and y_predicted have the same length.
:param H2OFrame y_actual:
:param H2OFrame y_predicted:
:returns: None
"""
if len(y_actual) != len(y_predicted):
raise ValueError("Row mismatch: [{},{}]".f... | python | {
"resource": ""
} |
q267279 | ModelBase.cross_validation_models | test | def cross_validation_models(self):
"""
Obtain a list of cross-validation models.
:returns: list of H2OModel objects.
"""
cvmodels = self._model_json["output"]["cross_validation_models"]
if cvmodels is None: return None
m = []
for p in cvmodels: m.append(h... | python | {
"resource": ""
} |
q267280 | gbm | test | def gbm(interactive=True, echo=True, testing=False):
"""GBM model demo."""
def demo_body(go):
"""
Demo of H2O's Gradient Boosting estimator.
This demo uploads a dataset to h2o, parses it, and shows a description.
Then it divides the dataset into training and test sets, builds a... | python | {
"resource": ""
} |
q267281 | deeplearning | test | def deeplearning(interactive=True, echo=True, testing=False):
"""Deep Learning model demo."""
def demo_body(go):
"""
Demo of H2O's Deep Learning model.
This demo uploads a dataset to h2o, parses it, and shows a description.
Then it divides the dataset into training and test set... | python | {
"resource": ""
} |
q267282 | glm | test | def glm(interactive=True, echo=True, testing=False):
"""GLM model demo."""
def demo_body(go):
"""
Demo of H2O's Generalized Linear Estimator.
This demo uploads a dataset to h2o, parses it, and shows a description.
Then it divides the dataset into training and test sets, builds ... | python | {
"resource": ""
} |
q267283 | _wait_for_keypress | test | def _wait_for_keypress():
"""
Wait for a key press on the console and return it.
Borrowed from http://stackoverflow.com/questions/983354/how-do-i-make-python-to-wait-for-a-pressed-key
"""
result = None
if os.name == "nt":
# noinspection PyUnresolvedReferences
import msvcrt
... | python | {
"resource": ""
} |
q267284 | H2OTwoDimTable.as_data_frame | test | def as_data_frame(self):
"""Convert to a python 'data frame'."""
if can_use_pandas():
import pandas
pandas.options.display.max_colwidth = 70
return pandas.DataFrame(self._cell_values, columns=self._col_header)
return self | python | {
"resource": ""
} |
q267285 | H2OTwoDimTable.show | test | def show(self, header=True):
"""Print the contents of this table."""
# if h2o.can_use_pandas():
# import pandas
# pandas.options.display.max_rows = 20
# print pandas.DataFrame(self._cell_values,columns=self._col_header)
# return
if header and self._table_heade... | python | {
"resource": ""
} |
q267286 | H2OLocalServer.start | test | def start(jar_path=None, nthreads=-1, enable_assertions=True, max_mem_size=None, min_mem_size=None,
ice_root=None, log_dir=None, log_level=None, port="54321+", name=None, extra_classpath=None,
verbose=True, jvm_custom_args=None, bind_to_localhost=True):
"""
Start new H2O serv... | python | {
"resource": ""
} |
q267287 | H2OLocalServer._find_jar | test | def _find_jar(self, path0=None):
"""
Return the location of an h2o.jar executable.
:param path0: Explicitly given h2o.jar path. If provided, then we will simply check whether the file is there,
otherwise we will search for an executable in locations returned by ._jar_paths().
... | python | {
"resource": ""
} |
q267288 | H2OLocalServer._jar_paths | test | def _jar_paths():
"""Produce potential paths for an h2o.jar executable."""
# PUBDEV-3534 hook to use arbitrary h2o.jar
own_jar = os.getenv("H2O_JAR_PATH", "")
if own_jar != "":
if not os.path.isfile(own_jar):
raise H2OStartupError("Environment variable H2O_JA... | python | {
"resource": ""
} |
q267289 | H2OMultinomialModel.hit_ratio_table | test | def hit_ratio_table(self, train=False, valid=False, xval=False):
"""
Retrieve the Hit Ratios.
If all are False (default), then return the training metric value.
If more than one options is set to True, then return a dictionary of metrics where the keys are "train",
"valid", and ... | python | {
"resource": ""
} |
q267290 | csv_dict_writer | test | def csv_dict_writer(f, fieldnames, **kwargs):
"""Equivalent of csv.DictWriter, but allows `delimiter` to be a unicode string on Py2."""
import csv
if "delimiter" in kwargs:
kwargs["delimiter"] = str(kwargs["delimiter"])
return csv.DictWriter(f, fieldnames, **kwargs) | python | {
"resource": ""
} |
q267291 | ApiDocWriter._uri2path | test | def _uri2path(self, uri):
''' Convert uri to absolute filepath
Parameters
----------
uri : string
URI of python module to return path for
Returns
-------
path : None or string
Returns None if there is no valid path for this URI
... | python | {
"resource": ""
} |
q267292 | ApiDocWriter._path2uri | test | def _path2uri(self, dirpath):
''' Convert directory path to uri '''
relpath = dirpath.replace(self.root_path, self.package_name)
if relpath.startswith(os.path.sep):
relpath = relpath[1:]
return relpath.replace(os.path.sep, '.') | python | {
"resource": ""
} |
q267293 | ApiDocWriter._parse_lines | test | def _parse_lines(self, linesource):
''' Parse lines of text for functions and classes '''
functions = []
classes = []
for line in linesource:
if line.startswith('def ') and line.count('('):
# exclude private stuff
name = self._get_object_name(l... | python | {
"resource": ""
} |
q267294 | ApiDocWriter.generate_api_doc | test | def generate_api_doc(self, uri):
'''Make autodoc documentation template string for a module
Parameters
----------
uri : string
python location of module - e.g 'sphinx.builder'
Returns
-------
S : string
Contents of API doc
'''
... | python | {
"resource": ""
} |
q267295 | ApiDocWriter.discover_modules | test | def discover_modules(self):
''' Return module sequence discovered from ``self.package_name``
Parameters
----------
None
Returns
-------
mods : sequence
Sequence of module names within ``self.package_name``
Examples
--------
... | python | {
"resource": ""
} |
q267296 | ApiDocWriter.write_api_docs | test | def write_api_docs(self, outdir):
"""Generate API reST files.
Parameters
----------
outdir : string
Directory name in which to store files
We create automatic filenames for each module
Returns
-------
None
Notes
... | python | {
"resource": ""
} |
q267297 | ApiDocWriter.write_index | test | def write_index(self, outdir, froot='gen', relative_to=None):
"""Make a reST API index file from written files
Parameters
----------
path : string
Filename to write index to
outdir : string
Directory to which to write generated index file
froot : ... | python | {
"resource": ""
} |
q267298 | ConfusionMatrix.to_list | test | def to_list(self):
"""Convert this confusion matrix into a 2x2 plain list of values."""
return [[int(self.table.cell_values[0][1]), int(self.table.cell_values[0][2])],
[int(self.table.cell_values[1][1]), int(self.table.cell_values[1][2])]] | python | {
"resource": ""
} |
q267299 | load_dict | test | def load_dict():
"""
Load java messages that can be ignored pickle file into a dict structure g_ok_java_messages.
:return: none
"""
global g_load_java_message_filename
global g_ok_java_messages
if os.path.isfile(g_load_java_message_filename):
# only load dict from file if it ex... | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.