Skip to content

Commit

Permalink
Clean up PR for merge
Browse files Browse the repository at this point in the history
  • Loading branch information
rhiever committed Mar 22, 2017
2 parents aedf9ea + 965aa7c commit 6c18d25
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 87 deletions.
17 changes: 11 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
[![Build Status](https://travis-ci.org/rhiever/tpot.svg?branch=master)](https://travis-ci.org/rhiever/tpot)
[![Code Health](https://landscape.io/github/rhiever/tpot/master/landscape.svg?style=flat)](https://landscape.io/github/rhiever/tpot/master)
[![Coverage Status](https://coveralls.io/repos/rhiever/tpot/badge.svg?branch=master&service=github)](https://coveralls.io/github/rhiever/tpot?branch=master)
![Python 2.7](https://img.shields.io/badge/python-2.7-blue.svg)
![Python 3.5](https://img.shields.io/badge/python-3.5-blue.svg)
Master status: [![Master Build Status](https://travis-ci.org/rhiever/tpot.svg?branch=master)](https://travis-ci.org/rhiever/tpot)
[![Master Code Health](https://landscape.io/github/rhiever/tpot/master/landscape.svg?style=flat)](https://landscape.io/github/rhiever/tpot/master)
[![Master Coverage Status](https://coveralls.io/repos/rhiever/tpot/badge.svg?branch=master&service=github)](https://coveralls.io/github/rhiever/tpot?branch=master)

Development status: [![Development Build Status](https://travis-ci.org/rhiever/tpot.svg?branch=development)](https://travis-ci.org/rhiever/tpot)
[![Development Code Health](https://landscape.io/github/rhiever/tpot/development/landscape.svg?style=flat)](https://landscape.io/github/rhiever/tpot/development)
[![Development Coverage Status](https://coveralls.io/repos/rhiever/tpot/badge.svg?branch=development&service=github)](https://coveralls.io/github/rhiever/tpot?branch=development)

Package information: ![Python 2.7](https://img.shields.io/badge/python-2.7-blue.svg)
![Python 3.5](https://img.shields.io/badge/python-3.6-blue.svg)
![License](https://img.shields.io/badge/license-GPLv3-blue.svg)
[![PyPI version](https://badge.fury.io/py/tpot.svg)](https://badge.fury.io/py/tpot)
[![PyPI version](https://badge.fury.io/py/TPOT.svg)](https://badge.fury.io/py/TPOT)

[![Join the chat at https://gitter.im/rhiever/tpot](https://badges.gitter.im/rhiever/tpot.svg)](https://gitter.im/rhiever/tpot?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

Expand Down
62 changes: 0 additions & 62 deletions conda_recipes/tpot/meta.yaml

This file was deleted.

3 changes: 1 addition & 2 deletions docs/sitemap.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
<lastmod>2017-03-22</lastmod>
<changefreq>daily</changefreq>
</url>



<url>
Expand Down Expand Up @@ -65,4 +64,4 @@
</url>


</urlset>
</urlset>
10 changes: 2 additions & 8 deletions tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,6 @@ def isclose(a, b, rel_tol=1e-09, abs_tol=0.0):
assert not np.allclose(cv_score1, cv_score_weight)
assert isclose(known_score, score)


def test_predict():
"""Assert that the TPOT predict function raises a RuntimeError when no optimized pipeline exists"""

Expand Down Expand Up @@ -342,7 +341,6 @@ def test_predict_2():

assert result.shape == (testing_features.shape[0],)


def test_predict_proba():
"""Assert that the TPOT predict_proba function returns a numpy matrix of shape (num_testing_rows, num_testing_classes)"""

Expand Down Expand Up @@ -400,7 +398,6 @@ def test_warm_start():

assert tpot_obj._pop == first_pop


def test_fit():
"""Assert that the TPOT fit function provides an optimized pipeline"""
tpot_obj = TPOTClassifier(random_state=42, population_size=1, offspring_size=2, generations=1, verbosity=0)
Expand Down Expand Up @@ -519,8 +516,7 @@ def test_generate_pipeline_code():
def test_generate_import_code():
"""Assert that generate_import_code() returns the correct set of dependancies for a given pipeline"""
tpot_obj = TPOTClassifier()
pipeline = creator.Individual.\
from_string('GaussianNB(RobustScaler(input_matrix))', tpot_obj._pset)
pipeline = creator.Individual.from_string('GaussianNB(RobustScaler(input_matrix))', tpot_obj._pset)

expected_code = """import numpy as np
Expand Down Expand Up @@ -562,7 +558,7 @@ def test_mutNodeReplacement():


def test_export_pipeline():
"""Assert that exported_pipeline() generated a compile source file as expected given a fixed complex pipeline"""
"""Assert that exported_pipeline() generated a compile source file as expected given a fixed pipeline"""
tpot_obj = TPOTClassifier()
pipeline_string= ('KNeighborsClassifier(CombineDFs('
'DecisionTreeClassifier(input_matrix, DecisionTreeClassifier__criterion=gini'
Expand Down Expand Up @@ -603,7 +599,6 @@ def test_export_pipeline():
"""
assert expected_code == export_pipeline(pipeline, tpot_obj.operators, tpot_obj._pset)


def test_export_pipeline_2():
"""Assert that exported_pipeline() generated a compile source file as expected given a fixed simple pipeline (only one classifier)"""
tpot_obj = TPOTClassifier()
Expand Down Expand Up @@ -659,7 +654,6 @@ def test_export_pipeline_3():
"""
assert expected_code == export_pipeline(pipeline, tpot_obj.operators, tpot_obj._pset)


def test_operator_export():
"""Assert that a TPOT operator can export properly with a function as a parameter to a classifier"""
export_string = TPOTSelectKBest.export(5)
Expand Down
2 changes: 1 addition & 1 deletion tpot/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@
"""

__version__ = '0.7'
__version__ = '0.7.0'
9 changes: 4 additions & 5 deletions tpot/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
from ._version import __version__
from .operator_utils import TPOTOperatorClassFactory, Operator, ARGType, set_sample_weight
from .export_utils import export_pipeline, expr_to_tree, generate_pipeline_code

from .decorators import _timeout, _pre_test, TimedOutExc
from .built_in_operators import CombineDFs

Expand All @@ -69,6 +68,7 @@ def handler(dwCtrlType, hook_sigint=_thread.interrupt_main):
return 0
win32api.SetConsoleCtrlHandler(handler, 1)


class TPOTBase(BaseEstimator):
"""TPOT automatically creates and optimizes machine learning pipelines using genetic programming"""

Expand Down Expand Up @@ -612,6 +612,7 @@ def _set_param_recursive(self, pipeline_steps, parameter, value):
"""
for (_, obj) in pipeline_steps:
recursive_attrs = ['steps', 'transformer_list', 'estimators']

for attr in recursive_attrs:
if hasattr(obj, attr):
self._set_param_recursive(getattr(obj, attr), parameter, value)
Expand All @@ -620,7 +621,6 @@ def _set_param_recursive(self, pipeline_steps, parameter, value):
if hasattr(obj, parameter):
setattr(obj, parameter, value)


def _evaluate_individuals(self, individuals, features, classes, sample_weight = None):
"""Determines the `individual`'s fitness
Expand Down Expand Up @@ -660,7 +660,7 @@ def _evaluate_individuals(self, individuals, features, classes, sample_weight =
# This is a fairly hacky way to prevent TPOT from getting stuck on bad pipelines and should be improved in a future release
individual = individuals[indidx]
individual_str = str(individual)
if (individual_str.count('PolynomialFeatures') > 1):
if individual_str.count('PolynomialFeatures') > 1:
if self.verbosity > 2:
self._pbar.write('Invalid pipeline encountered. Skipping its evaluation.')
fitnesses_dict[indidx] = (5000., -float('inf'))
Expand Down Expand Up @@ -745,6 +745,7 @@ def _wrapped_cross_val_score(sklearn_pipeline, features=features, classes=classe
else:
time.sleep(0.2)
resulting_score_list = [-float('inf') if x == 'Timeout' else x for x in list(res_imap)]

else:
resulting_score_list = []
for sklearn_pipeline in sklearn_pipeline_list:
Expand Down Expand Up @@ -775,7 +776,6 @@ def _wrapped_cross_val_score(sklearn_pipeline, features=features, classes=classe
def _mate_operator(self, ind1, ind2):
return gp.cxOnePoint(ind1, ind2)


@_pre_test
def _random_mutation_operator(self, individual):
"""Perform a replacement, insertion, or shrink mutation on an individual
Expand All @@ -801,7 +801,6 @@ def _random_mutation_operator(self, individual):
]
return np.random.choice(mutation_techniques)(individual)


def _gen_grow_safe(self, pset, min_, max_, type_=None):
"""Generate an expression where each leaf might have a different depth
between min_ and max_.
Expand Down
3 changes: 0 additions & 3 deletions tpot/export_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,6 @@ def generate_import_code(pipeline, operators):
# number of operators
num_op = len(operators_used)



# Build dict of import requirments from list of operators
import_relations = {}
for op in operators:
Expand Down Expand Up @@ -270,7 +268,6 @@ def generate_export_pipeline_code(pipeline_tree, operators):

return pipeline_text


def process_operator(operator, operators, depth=0):
steps = []
op_name = operator[0]
Expand Down

0 comments on commit 6c18d25

Please sign in to comment.