Skip to content

Commit

Permalink
Small changes to stream and DEMO notebook, also changing the config.i…
Browse files Browse the repository at this point in the history
…ni to use a relative path.
  • Loading branch information
hmgomes committed Oct 20, 2023
1 parent 94d3673 commit 6716f1f
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 31 deletions.
83 changes: 56 additions & 27 deletions DEMO.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion config.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[Paths]
moa_jar_path = /Users/gomeshe/Dropbox/ciencia_computacao/dev/main-projects/MOABridge/jar/moa.jar
moa_jar_path = ./jar/moa.jar

[JVM]
args = -Xmx8g -Xss10M
8 changes: 5 additions & 3 deletions stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@



# IDEA: STATIC METHOD TO CREATE A SCHEMA USING A MOA_HEADER. (e.g. withMOAHeader...)
# TODO: STATIC METHOD TO CREATE A SCHEMA USING A MOA_HEADER. (e.g. withMOAHeader...)
class Schema:
"""
This class is a wrapper for the MOA header, but it can be set up in Python directly by specifying the labels attribute.
Expand Down Expand Up @@ -130,6 +130,9 @@ def __init__(self, schema=None, CLI=None, moa_stream=None):
def __str__(self):
return str(self.moa_stream.getHeader().getRelationName()).replace(' ', '')

def CLI_help(self):
return str(self.moa_stream.getOptions().getHelpString())

def has_more_instances(self):
return self.moa_stream.hasMoreInstances()

Expand Down Expand Up @@ -217,7 +220,7 @@ def __init__(self, schema=None, CLI=None, instance_random_seed=1, tree_random_se

super().__init__(schema=schema, CLI=self.CLI, moa_stream=self.moa_stream)


## TODO (20/10/2023): Add logic to interpret nominal values (strings) in the class label.
## TODO: add extra fluffiness like allowing to not have a header for the csv (then we need to create names for each column).
## TODO: if no name is given for the dataset_name, we can use the file name from the csv.
## TODO: implement class_index logic when reading from a CSV.
Expand All @@ -242,7 +245,6 @@ def stream_from_file(schema=None, path_to_csv_or_arff="", class_index=-1, datase

return NumpyStream(X=X, y=y.astype(int), dataset_name="Elec", feature_names=header[:-1], target_name=header[-1], enforce_regression=enforce_regression)


def numpy_to_ARFF(X, y, dataset_name="No_Name", feature_names=None, target_name=None, enforce_regression=False):
'''
Converts a numpy X and y into a ARFF format. The code infers whether it is a classification or regression problem
Expand Down

0 comments on commit 6716f1f

Please sign in to comment.