_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 31 13.1k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q24000 | SubDomainEnumerator._extract_from_sans | train | def _extract_from_sans(self):
"""Looks for different TLDs as well as different sub-domains in SAN list"""
self.logger.info("{} Trying to find Subdomains in SANs list".format(COLORED_COMBOS.NOTIFY))
if self.host.naked:
domain = self.host.naked
tld_less = domain.split(".")[... | python | {
"resource": ""
} |
q24001 | RequestHandler.get_new_session | train | def get_new_session(self):
"""Returns a new session using the object's proxies and headers"""
session = Session()
| python | {
"resource": ""
} |
q24002 | HelpUtilities.validate_port_range | train | def validate_port_range(cls, port_range):
"""Validate port range for Nmap scan"""
ports = port_range.split("-")
if all(ports) and int(ports[-1]) <= 65535 and not len(ports) != | python | {
"resource": ""
} |
q24003 | HelpUtilities.create_output_directory | train | def create_output_directory(cls, outdir):
"""Tries to create base output directory"""
| python | {
"resource": ""
} |
q24004 | FixParser.add_raw | train | def add_raw(self, length_tag, value_tag):
"""Define the tags used for a private raw data field.
:param length_tag: tag number of length field.
:param value_tag: tag number of value field.
Data fields are not terminated by the SOH character as is usual for
FIX, but instead have ... | python | {
"resource": ""
} |
q24005 | FixParser.remove_raw | train | def remove_raw(self, length_tag, value_tag):
"""Remove the tags for a data type field.
:param length_tag: tag number of the length field.
:param value_tag: tag number of the value field.
You can remove either private or standard data field definitions in
case a particular appli... | python | {
"resource": ""
} |
q24006 | FixParser.get_message | train | def get_message(self):
"""Process the accumulated buffer and return the first message.
If the buffer starts with FIX fields other than BeginString
(8), these are discarded until the start of a message is
found.
If no BeginString (8) field is found, this function returns
... | python | {
"resource": ""
} |
q24007 | fix_val | train | def fix_val(value):
"""Make a FIX value from a string, bytes, or number."""
if type(value) == bytes:
return value
if sys.version_info[0] == 2:
| python | {
"resource": ""
} |
q24008 | fix_tag | train | def fix_tag(value):
"""Make a FIX tag value from string, bytes, or integer."""
if sys.version_info[0] == 2:
return bytes(value)
else:
if type(value) == bytes:
return value
| python | {
"resource": ""
} |
q24009 | FixMessage.append_pair | train | def append_pair(self, tag, value, header=False):
"""Append a tag=value pair to this message.
:param tag: Integer or string FIX tag number.
:param value: FIX tag value.
:param header: Append to header if True; default to body.
Both parameters are explicitly converted to strings ... | python | {
"resource": ""
} |
q24010 | FixMessage.append_time | train | def append_time(self, tag, timestamp=None, precision=3, utc=True,
header=False):
"""Append a time field to this message.
:param tag: Integer or string FIX tag number.
:param timestamp: Time (see below) value to append, or None for now.
:param precision: Number of dec... | python | {
"resource": ""
} |
q24011 | FixMessage.append_utc_timestamp | train | def append_utc_timestamp(self, tag, timestamp=None, precision=3,
header=False):
"""Append a field with a UTCTimestamp value.
:param tag: Integer or string FIX tag number.
:param timestamp: Time value, see below.
:param precision: Number of decimal places: 0,... | python | {
"resource": ""
} |
q24012 | FixMessage.append_utc_time_only | train | def append_utc_time_only(self, tag, timestamp=None, precision=3,
header=False):
"""Append a field with a UTCTimeOnly value.
:param tag: Integer or string FIX tag number.
:param timestamp: Time value, see below.
:param precision: Number of decimal places: 0, ... | python | {
"resource": ""
} |
q24013 | FixMessage.append_tz_timestamp | train | def append_tz_timestamp(self, tag, timestamp=None, precision=3,
header=False):
"""Append a field with a TZTimestamp value, derived from local time.
:param tag: Integer or string FIX tag number.
:param timestamp: Time value, see below.
:param precision: Number... | python | {
"resource": ""
} |
q24014 | FixMessage.append_tz_time_only | train | def append_tz_time_only(self, tag, timestamp=None, precision=3,
header=False):
"""Append a field with a TZTimeOnly value.
:param tag: Integer or string FIX tag number.
:param timestamp: Time value, see below.
:param precision: Number of decimal places: 0, 3 (... | python | {
"resource": ""
} |
q24015 | FixMessage.append_tz_time_only_parts | train | def append_tz_time_only_parts(self, tag, h, m, s=None, ms=None, us=None,
offset=0, header=False):
"""Append a field with a TZTimeOnly value from components.
:param tag: Integer or string FIX tag number.
:param h: Hours, in range 0 to 23.
:param m: Minut... | python | {
"resource": ""
} |
q24016 | FixMessage.append_string | train | def append_string(self, field, header=False):
"""Append a tag=value pair in string format.
:param field: String "tag=value" to be appended to this message.
:param header: Append to header if True; default to body.
The string is split at the first '=' character, and the resulting
... | python | {
"resource": ""
} |
q24017 | FixMessage.append_strings | train | def append_strings(self, string_list, header=False):
"""Append tag=pairs for each supplied string.
:param string_list: List of "tag=value" strings.
:param header: Append | python | {
"resource": ""
} |
q24018 | FixMessage.append_data | train | def append_data(self, len_tag, val_tag, data, header=False):
"""Append raw data, possibly including a embedded SOH.
:param len_tag: Tag number for length field.
:param val_tag: Tag number for value field.
:param data: Raw data byte string.
:param header: Append to header if True... | python | {
"resource": ""
} |
q24019 | FixMessage.get | train | def get(self, tag, nth=1):
"""Return n-th value for tag.
:param tag: FIX field tag number.
:param nth: Index of tag if repeating, first is 1.
:return: None if nothing found, otherwise value matching tag.
Defaults to returning the first matching value of 'tag', but if
th... | python | {
"resource": ""
} |
q24020 | FixMessage.remove | train | def remove(self, tag, nth=1):
"""Remove the n-th occurrence of tag in this message.
:param tag: FIX field tag number to be removed.
:param nth: Index of tag if repeating, first is 1.
:returns: Value of the field if removed, None otherwise."""
tag = fix_tag(tag)
nth = in... | python | {
"resource": ""
} |
q24021 | FixMessage.encode | train | def encode(self, raw=False):
"""Convert message to on-the-wire FIX format.
:param raw: If True, encode pairs exactly as provided.
Unless 'raw' is set, this function will calculate and
correctly set the BodyLength (9) and Checksum (10) fields, and
ensure that the BeginString (8)... | python | {
"resource": ""
} |
q24022 | is_suspicious | train | def is_suspicious( pe ):
"""
unusual locations of import tables
non recognized section names
presence of long ASCII strings
"""
relocations_overlap_entry_point = False
sequential_relocs = 0
# If relocation data is found and the entries go over the entry point, and also are very
# c... | python | {
"resource": ""
} |
q24023 | is_probably_packed | train | def is_probably_packed( pe ):
"""Returns True is there is a high likelihood that a file is packed or contains compressed data.
The sections of the PE file will be analyzed, if enough sections
look like containing compressed data and the data makes
up for more than 20% of the total file size, the functi... | python | {
"resource": ""
} |
q24024 | SignatureDatabase.generate_section_signatures | train | def generate_section_signatures(self, pe, name, sig_length=512):
"""Generates signatures for all the sections in a PE file.
If the section contains any data a signature will be created
for it. The signature name will be a combination of the
parameter 'name' and the section number and it... | python | {
"resource": ""
} |
q24025 | SignatureDatabase.generate_ep_signature | train | def generate_ep_signature(self, pe, name, sig_length=512):
"""Generate signatures for the entry point of a PE file.
Creates a signature whose name will be the parameter 'name'
and the section number and its name.
"""
offset = | python | {
"resource": ""
} |
q24026 | SignatureDatabase.__match_signature_tree | train | def __match_signature_tree(self, signature_tree, data, depth = 0):
"""Recursive function to find matches along the signature tree.
signature_tree is the part of the tree left to walk
data is the data being checked against the signature tree
depth keeps track of how far we have gon... | python | {
"resource": ""
} |
q24027 | SignatureDatabase.load | train | def load(self , filename=None, data=None):
"""Load a PEiD signature file.
Invoking this method on different files | python | {
"resource": ""
} |
q24028 | _read_doc | train | def _read_doc():
"""
Parse docstring from file 'pefile.py' and avoid importing
this module directly.
"""
if sys.version_info.major == 2:
with open('pefile.py', 'r') as f:
tree = ast.parse(f.read())
else:
| python | {
"resource": ""
} |
q24029 | _read_attr | train | def _read_attr(attr_name):
"""
Parse attribute from file 'pefile.py' and avoid importing
this module directly.
__version__, __author__, __contact__,
"""
regex = attr_name + r"\s+=\s+'(.+)'"
if sys.version_info.major == 2:
with open('pefile.py', 'r') as f:
match = re.sear... | python | {
"resource": ""
} |
q24030 | ordLookup | train | def ordLookup(libname, ord_val, make_name=False):
'''
Lookup a name for the given ordinal if it's in our
database.
'''
names = ords.get(libname.lower())
if names is None:
if make_name is True:
return formatOrdString(ord_val)
| python | {
"resource": ""
} |
q24031 | retrieve_flags | train | def retrieve_flags(flag_dict, flag_filter):
"""Read the flags from a dictionary and return them in a usable form.
Will return a list of (flag, value) for all flags in "flag_dict"
matching the filter "flag_filter".
""" | python | {
"resource": ""
} |
q24032 | UnicodeStringWrapperPostProcessor.ask_unicode_16 | train | def ask_unicode_16(self, next_rva_ptr):
"""The next RVA is taken to be the one immediately following this one.
Such RVA could indicate the natural end of the string and will be checked
to see if there's a Unicode NULL character there.
"""
| python | {
"resource": ""
} |
q24033 | Dump.add_lines | train | def add_lines(self, txt, indent=0):
"""Adds a list of lines.
The list can | python | {
"resource": ""
} |
q24034 | Dump.add | train | def add(self, txt, indent=0):
"""Adds some text, no newline will be appended.
| python | {
"resource": ""
} |
q24035 | Dump.get_text | train | def get_text(self):
"""Get the text in its current state."""
| python | {
"resource": ""
} |
q24036 | Structure.dump_dict | train | def dump_dict(self):
"""Returns a dictionary representation of the structure."""
dump_dict = dict()
dump_dict['Structure'] = self.name
# Refer to the __set_format__ method for an explanation
# of the following construct.
for keys in self.__keys__:
for key i... | python | {
"resource": ""
} |
q24037 | SectionStructure.get_data | train | def get_data(self, start=None, length=None):
"""Get data chunk from a section.
Allows to query data from the section by passing the
addresses where the PE file would be loaded by default.
It is then possible to retrieve code and data by their real
addresses as they would be if l... | python | {
"resource": ""
} |
q24038 | PE.full_load | train | def full_load(self):
"""Process the data directories.
This method will load the data directories which might not have
been loaded if the "fast_load" option was used.
"""
self.parse_data_directories()
class RichHeader(object):
pass
rich_header = self... | python | {
"resource": ""
} |
q24039 | PE.write | train | def write(self, filename=None):
"""Write the PE file.
This function will process all headers and components
of the PE file and include all changes made (by just
assigning to attributes in the PE objects) and write
the changes back to a file whose name is provided as
an a... | python | {
"resource": ""
} |
q24040 | PE.parse_data_directories | train | def parse_data_directories(self, directories=None,
forwarded_exports_only=False,
import_dllnames_only=False):
"""Parse and process the PE file's data directories.
If the optional argument 'directories' is given, only
the directories ... | python | {
"resource": ""
} |
q24041 | PE.parse_resource_data_entry | train | def parse_resource_data_entry(self, rva):
"""Parse a data entry from the resources directory."""
try:
# If the RVA is invalid all would blow up. Some EXEs seem to be
# specially nasty and have an invalid RVA.
data = self.get_data(rva, Structure(self.__IMAGE_RESOURCE_... | python | {
"resource": ""
} |
q24042 | PE.get_memory_mapped_image | train | def get_memory_mapped_image(self, max_virtual_address=0x10000000, ImageBase=None):
"""Returns the data corresponding to the memory layout of the PE file.
The data includes the PE header and the sections loaded at offsets
corresponding to their relative virtual addresses. (the VirtualAddress
... | python | {
"resource": ""
} |
q24043 | PE.get_string_from_data | train | def get_string_from_data(self, offset, data):
"""Get an ASCII string from data."""
s = self.get_bytes_from_data(offset, data)
| python | {
"resource": ""
} |
q24044 | PE.get_section_by_offset | train | def get_section_by_offset(self, offset):
"""Get the section containing the given file offset."""
| python | {
"resource": ""
} |
q24045 | PE.set_dword_at_rva | train | def set_dword_at_rva(self, rva, dword):
"""Set the double word value at the file | python | {
"resource": ""
} |
q24046 | PE.set_dword_at_offset | train | def set_dword_at_offset(self, offset, dword):
"""Set the double word value | python | {
"resource": ""
} |
q24047 | PE.set_word_at_rva | train | def set_word_at_rva(self, rva, word):
"""Set the word value at the file offset corresponding to the given RVA."""
| python | {
"resource": ""
} |
q24048 | PE.set_word_at_offset | train | def set_word_at_offset(self, offset, word):
"""Set the word value at the given file offset."""
| python | {
"resource": ""
} |
q24049 | PE.set_qword_at_rva | train | def set_qword_at_rva(self, rva, qword):
"""Set the quad-word value at the file | python | {
"resource": ""
} |
q24050 | PE.set_qword_at_offset | train | def set_qword_at_offset(self, offset, qword):
"""Set the quad-word value at the given file offset."""
| python | {
"resource": ""
} |
q24051 | PE.set_bytes_at_rva | train | def set_bytes_at_rva(self, rva, data):
"""Overwrite, with the given string, the bytes at the file offset corresponding to the given RVA.
Return True if successful, False otherwise. It can fail if the
offset is outside the file's boundaries.
"""
if not isinstance(data, | python | {
"resource": ""
} |
q24052 | PE.set_bytes_at_offset | train | def set_bytes_at_offset(self, offset, data):
"""Overwrite the bytes at the given file offset with the given string.
Return True if successful, False otherwise. It can fail if the
offset is outside the file's boundaries.
"""
if not isinstance(data, bytes):
| python | {
"resource": ""
} |
q24053 | PE.relocate_image | train | def relocate_image(self, new_ImageBase):
"""Apply the relocation information to the image using the provided new image base.
This method will apply the relocation information to the image. Given the new base,
all the relocations will be processed and both the raw data and the section's data
... | python | {
"resource": ""
} |
q24054 | PE.is_exe | train | def is_exe(self):
"""Check whether the file is a standard executable.
This will return true only if the file has the IMAGE_FILE_EXECUTABLE_IMAGE flag set
and the IMAGE_FILE_DLL not set and the file does not appear to be a driver either.
"""
EXE_flag = IMAGE_CHARACTERISTICS['IMA... | python | {
"resource": ""
} |
q24055 | PE.is_dll | train | def is_dll(self):
"""Check whether the file is a standard DLL.
This will return true only if the image has the IMAGE_FILE_DLL flag set. | python | {
"resource": ""
} |
q24056 | PE.is_driver | train | def is_driver(self):
"""Check whether the file is a Windows driver.
This will return true only if there are reliable indicators of the image
being a driver.
"""
# Checking that the ImageBase field of the OptionalHeader is above or
# equal to 0x80000000 (that is, whether... | python | {
"resource": ""
} |
q24057 | PE.trim | train | def trim(self):
"""Return the just data defined by the PE headers, removing any overlayed data."""
overlay_data_offset = | python | {
"resource": ""
} |
q24058 | ImageExtractor.filter_bad_names | train | def filter_bad_names(self, images):
"""\
takes a list of image elements
and filters out the ones with bad names
"""
good_images = []
for image in images:
| python | {
"resource": ""
} |
q24059 | ImageExtractor.get_local_image | train | def get_local_image(self, src):
"""\
returns the bytes of the image file on disk
| python | {
"resource": ""
} |
q24060 | smart_unicode | train | def smart_unicode(s, encoding='utf-8', strings_only=False, errors='strict'):
"""
Returns a unicode object representing 's'. Treats bytestrings using the
'encoding' codec.
| python | {
"resource": ""
} |
q24061 | force_unicode | train | def force_unicode(s, encoding='utf-8', strings_only=False, errors='strict'):
"""
Similar to smart_unicode, except that lazy instances are resolved to
strings, rather than kept as lazy objects.
If strings_only is True, don't convert (some) non-string-like objects.
"""
# Handle the common case fi... | python | {
"resource": ""
} |
q24062 | ContentExtractor.get_language | train | def get_language(self):
"""\
Returns the language is by the article or
the configuration language
"""
# we don't want to force the target language
# so we use the article.meta_lang
if self.config.use_meta_language:
| python | {
"resource": ""
} |
q24063 | ContentExtractor.get_siblings_score | train | def get_siblings_score(self, top_node):
"""\
we could have long articles that have tons of paragraphs
so if we tried to calculate the base score against
the total text score of those paragraphs it would be unfair.
So we need to normalize the score based on the average scoring
... | python | {
"resource": ""
} |
q24064 | ContentExtractor.update_score | train | def update_score(self, node, addToScore):
"""\
adds a score to the gravityScore Attribute we put on divs
we'll get the current score then add the score
we're passing in to the current
"""
current_score = 0
score_string = self.parser.getAttribute(node, 'gravityScor... | python | {
"resource": ""
} |
q24065 | ContentExtractor.update_node_count | train | def update_node_count(self, node, add_to_count):
"""\
stores how many decent nodes are under a parent node
"""
current_score = 0
count_string = self.parser.getAttribute(node, 'gravityNodes')
if count_string:
| python | {
"resource": ""
} |
q24066 | ContentExtractor.is_highlink_density | train | def is_highlink_density(self, e):
"""\
checks the density of links within a node,
is there not much text and most of it contains linky shit?
if so it's no good
"""
links = self.parser.getElementsByTag(e, tag='a')
if links is None or len(links) == 0:
re... | python | {
"resource": ""
} |
q24067 | ContentExtractor.post_cleanup | train | def post_cleanup(self):
"""\
remove any divs that looks like non-content,
clusters of links, or paras with no gusto
"""
targetNode = self.article.top_node
node = self.add_siblings(targetNode)
for e in self.parser.getChildren(node):
e_tag = self.parser.... | python | {
"resource": ""
} |
q24068 | VideoExtractor.get_video | train | def get_video(self, node):
"""
Create a video object from a video embed
"""
video = Video()
video.embed_code = self.get_embed_code(node)
| python | {
"resource": ""
} |
q24069 | ImageUtils.store_image | train | def store_image(self, http_client, link_hash, src, config):
"""\
Writes an image src http string to disk as a temporary file
and returns the LocallyStoredImage object
that has the info you should need on the image
"""
# | python | {
"resource": ""
} |
q24070 | OutputFormatter.remove_negativescores_nodes | train | def remove_negativescores_nodes(self):
"""\
if there are elements inside our top node
that have a negative gravity score,
let's give em the boot
"""
gravity_items = self.parser.css_select(self.top_node, "*[gravityScore]")
for item in gravity_items:
sco... | python | {
"resource": ""
} |
q24071 | OutputFormatter.remove_fewwords_paragraphs | train | def remove_fewwords_paragraphs(self):
"""\
remove paragraphs that have less than x number of words,
would indicate that it's some sort of link
"""
all_nodes = self.parser.getElementsByTags(self.get_top_node(), ['*'])
all_nodes.reverse()
for el in all_nodes:
... | python | {
"resource": ""
} |
q24072 | Goose.extract | train | def extract(self, url=None, raw_html=None):
"""\
Main method to extract an article object from a URL,
pass in a url and get back a Article
"""
| python | {
"resource": ""
} |
q24073 | MetasExtractor.get_meta_lang | train | def get_meta_lang(self):
"""\
Extract content language from meta
"""
# we have a lang attribute in html
attr = self.parser.getAttribute(self.article.doc, attr='lang')
if attr is None:
# look up for a Content-Language in meta
items = [
... | python | {
"resource": ""
} |
q24074 | MetasExtractor.get_meta_content | train | def get_meta_content(self, metaName):
"""\
Extract a given meta content form document
"""
meta = self.parser.css_select(self.article.doc, metaName)
content = None
if meta is not None and len(meta) > 0:
| python | {
"resource": ""
} |
q24075 | BaseSymbolic._verbose_reporter | train | def _verbose_reporter(self, run_details=None):
"""A report of the progress of the evolution process.
Parameters
----------
run_details : dict
Information about the evolution.
"""
if run_details is None:
print(' |{:^25}|{:^42}|'.format('Populat... | python | {
"resource": ""
} |
q24076 | SymbolicRegressor.predict | train | def predict(self, X):
"""Perform regression on test vectors X.
Parameters
----------
X : array-like, shape = [n_samples, n_features]
Input vectors, where n_samples is the number of samples
and n_features is the number of features.
Returns
-------... | python | {
"resource": ""
} |
q24077 | SymbolicClassifier.predict_proba | train | def predict_proba(self, X):
"""Predict probabilities on test vectors X.
Parameters
----------
X : array-like, shape = [n_samples, n_features]
Input vectors, where n_samples is the number of samples
and n_features is the number of features.
Returns
... | python | {
"resource": ""
} |
q24078 | SymbolicClassifier.predict | train | def predict(self, X):
"""Predict classes on test vectors X.
Parameters
----------
X : array-like, shape = [n_samples, n_features]
Input vectors, where n_samples is the number of samples
| python | {
"resource": ""
} |
q24079 | SymbolicTransformer.transform | train | def transform(self, X):
"""Transform X according to the fitted transformer.
Parameters
----------
X : array-like, shape = [n_samples, n_features]
Input vectors, where n_samples is the number of samples
and n_features is the number of features.
Returns
... | python | {
"resource": ""
} |
q24080 | make_fitness | train | def make_fitness(function, greater_is_better):
"""Make a fitness measure, a metric scoring the quality of a program's fit.
This factory function creates a fitness measure object which measures the
quality of a program's fit and thus its likelihood to undergo genetic
operations into the next generation.... | python | {
"resource": ""
} |
q24081 | _weighted_pearson | train | def _weighted_pearson(y, y_pred, w):
"""Calculate the weighted Pearson correlation coefficient."""
with np.errstate(divide='ignore', invalid='ignore'):
y_pred_demean = y_pred - np.average(y_pred, weights=w)
y_demean = y - np.average(y, weights=w)
corr = ((np.sum(w * y_pred_demean * y_dem... | python | {
"resource": ""
} |
q24082 | _weighted_spearman | train | def _weighted_spearman(y, y_pred, w):
"""Calculate the weighted Spearman correlation coefficient."""
y_pred_ranked = np.apply_along_axis(rankdata, 0, y_pred)
y_ranked | python | {
"resource": ""
} |
q24083 | _mean_absolute_error | train | def _mean_absolute_error(y, y_pred, w):
"""Calculate the mean absolute error."""
return | python | {
"resource": ""
} |
q24084 | _mean_square_error | train | def _mean_square_error(y, y_pred, w):
"""Calculate the mean square error."""
return | python | {
"resource": ""
} |
q24085 | _root_mean_square_error | train | def _root_mean_square_error(y, y_pred, w):
"""Calculate the root mean square error."""
return | python | {
"resource": ""
} |
q24086 | _log_loss | train | def _log_loss(y, y_pred, w):
"""Calculate the log loss."""
eps = 1e-15
inv_y_pred = np.clip(1 - y_pred, eps, 1 - eps)
y_pred = np.clip(y_pred, eps, 1 - eps)
| python | {
"resource": ""
} |
q24087 | _Program.build_program | train | def build_program(self, random_state):
"""Build a naive random program.
Parameters
----------
random_state : RandomState instance
The random number generator.
Returns
-------
program : list
The flattened tree representation of the program... | python | {
"resource": ""
} |
q24088 | _Program.validate_program | train | def validate_program(self):
"""Rough check that the embedded program in the object is valid."""
terminals = [0]
for node in self.program:
if isinstance(node, _Function):
| python | {
"resource": ""
} |
q24089 | _Program.export_graphviz | train | def export_graphviz(self, fade_nodes=None):
"""Returns a string, Graphviz script for visualizing the program.
Parameters
----------
fade_nodes : list, optional
A list of node indices to fade out for showing which were removed
during evolution.
Returns
... | python | {
"resource": ""
} |
q24090 | _Program._depth | train | def _depth(self):
"""Calculates the maximum depth of the program tree."""
terminals = [0]
depth = 1
for node in self.program:
if isinstance(node, _Function):
| python | {
"resource": ""
} |
q24091 | _Program.execute | train | def execute(self, X):
"""Execute the program according to X.
Parameters
----------
X : {array-like}, shape = [n_samples, n_features]
Training vectors, where n_samples is the number of samples and
n_features is the number of features.
Returns
----... | python | {
"resource": ""
} |
q24092 | _Program.get_all_indices | train | def get_all_indices(self, n_samples=None, max_samples=None,
random_state=None):
"""Get the indices on which to evaluate the fitness of a program.
Parameters
----------
n_samples : int
The number of samples.
max_samples : int
The m... | python | {
"resource": ""
} |
q24093 | _Program.raw_fitness | train | def raw_fitness(self, X, y, sample_weight):
"""Evaluate the raw fitness of the program according to X, y.
Parameters
----------
X : {array-like}, shape = [n_samples, n_features]
Training vectors, where n_samples is the number of samples and
n_features is the numb... | python | {
"resource": ""
} |
q24094 | _Program.fitness | train | def fitness(self, parsimony_coefficient=None):
"""Evaluate the penalized fitness of the program according to X, y.
Parameters
----------
parsimony_coefficient : float, optional
If automatic parsimony is being used, the computed value according
to the population. ... | python | {
"resource": ""
} |
q24095 | _Program.get_subtree | train | def get_subtree(self, random_state, program=None):
"""Get a random subtree from the program.
Parameters
----------
random_state : RandomState instance
The random number generator.
program : list, optional (default=None)
The flattened tree representation ... | python | {
"resource": ""
} |
q24096 | _Program.crossover | train | def crossover(self, donor, random_state):
"""Perform the crossover genetic operation on the program.
Crossover selects a random subtree from the embedded program to be
replaced. A donor also has a subtree selected at random and this is
inserted into the original parent to form an offspr... | python | {
"resource": ""
} |
q24097 | _Program.subtree_mutation | train | def subtree_mutation(self, random_state):
"""Perform the subtree mutation operation on the program.
Subtree mutation selects a random subtree from the embedded program to
be replaced. A donor subtree is generated at random and this is
inserted into the original parent to form an offspri... | python | {
"resource": ""
} |
q24098 | _Program.hoist_mutation | train | def hoist_mutation(self, random_state):
"""Perform the hoist mutation operation on the program.
Hoist mutation selects a random subtree from the embedded program to
be replaced. A random subtree of that subtree is then selected and this
is 'hoisted' into the original subtrees location t... | python | {
"resource": ""
} |
q24099 | _Program.point_mutation | train | def point_mutation(self, random_state):
"""Perform the point mutation operation on the program.
Point mutation selects random nodes from the embedded program to be
replaced. Terminals are replaced by other terminals and functions are
replaced by other functions that require the same num... | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.