Skip to content

Commit

Permalink
Merge pull request #28 from lukapecnik/additional_improvements
Browse files Browse the repository at this point in the history
Readme update, encoder check for type int64
  • Loading branch information
lukapecnik committed Dec 7, 2020
2 parents 575510b + c3dcb2f commit 70ddb41
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 4 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ In case you would like to try out the latest pre-release version of the framewor
pip install niaaml --pre
```

## Graphical User Interface

There is a simple graphical user inteface for NiaAML package available [here](https://github.com/lukapecnik/NiaAML-GUI).

## Components

[Click here](COMPONENTS.md) for a list of currently implemented components divided into groups: classifiers, feature selection algorithms and feature transformation algorithms. At the end you can also see a list of currently implemented fitness functions for the optimization process and categorical features' encoders. All of the components are passed into the optimization process using their class names. Let's say we want to choose between Adaptive Boosting, Bagging and Multi Layer Perceptron classifiers, Select K Best and Select Percentile feature selection algorithms and Normalizer as the feature transformation algorithm (may not be selected during the optimization process).
Expand Down
5 changes: 5 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ In case you would like to try out the latest pre-release version of the framewor
pip install niaaml --pre
Graphical User Interface
------------------------

You can find a simple graphical user interface for NiaAML package `here <https://github.com/lukapecnik/NiaAML-GUI>`_.

Usage
-----

Expand Down
10 changes: 9 additions & 1 deletion niaaml/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,15 @@ def to_string(self):
feature_transform_algorithm_string = '\t' + self.__feature_transform_algorithm.to_string().replace('\n', '\n\t') if self.__feature_transform_algorithm is not None else '\tNone'
stats_string = '\t' + self.__best_stats.to_string().replace('\n', '\n\t') if self.__best_stats is not None else '\tStatistics is not available.'
features_string = '\t' + str(self.__selected_features_mask) if self.__selected_features_mask is not None else '\tFeature selection result is not available.'
return 'Classifier:\n{classifier}\n\nFeature selection algorithm:\n{fsa}\n\nFeature transform algorithm:\n{fta}\n\nMask of selected features (True if selected, False if not):\n{feat}\n\nStatistics:\n{stats}'.format(classifier=classifier_string, fsa=feature_selection_algorithm_string, fta=feature_transform_algorithm_string, feat=features_string, stats=stats_string)

encoders_string = ''
if self.__categorical_features_encoders is not None:
encoders_string += 'Categorical features encoders (in order):\n'
for i in range(len(self.__categorical_features_encoders)):
encoders_string += '\t* ' + self.__categorical_features_encoders[i].to_string() + '\n'
encoders_string += '\n'

return 'Classifier:\n{classifier}\n\nFeature selection algorithm:\n{fsa}\n\nFeature transform algorithm:\n{fta}\n\nMask of selected features (True if selected, False if not):\n{feat}\n\n{enc}Statistics:\n{stats}'.format(classifier=classifier_string, fsa=feature_selection_algorithm_string, fta=feature_transform_algorithm_string, enc=encoders_string, feat=features_string, stats=stats_string)

class _PipelineBenchmark(Benchmark):
r"""NiaPy Benchmark class implementation.
Expand Down
10 changes: 9 additions & 1 deletion niaaml/preprocessing/encoding/feature_encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,12 @@ def transform(self, feature):
Returns:
pandas.core.frame.DataFrame: A transformed column.
"""
return None
return None

def to_string(self):
r"""User friendly representation of the object.
Returns:
str: User friendly representation of the object.
"""
return '{name}'
10 changes: 9 additions & 1 deletion niaaml/preprocessing/encoding/one_hot_encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,12 @@ def transform(self, feature):
Returns:
pandas.core.frame.DataFrame: A transformed column.
"""
return pd.DataFrame(self.__one_hot_encoder.transform(feature).toarray())
return pd.DataFrame(self.__one_hot_encoder.transform(feature).toarray())

def to_string(self):
r"""User friendly representation of the object.
Returns:
str: User friendly representation of the object.
"""
return FeatureEncoder.to_string(self).format(name=self.Name)
2 changes: 1 addition & 1 deletion niaaml/preprocessing/encoding/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def encode_categorical_features(features, encoder):
to_drop = []
enc_features = pd.DataFrame()
for i in range(len(types)):
if types[i] != np.dtype('float64'):
if types[i] != np.dtype('float64') and types[i] != np.dtype('int64'):
enc.fit(features[[i]])
tr = enc.transform(features[[i]])
to_drop.append(i)
Expand Down

0 comments on commit 70ddb41

Please sign in to comment.