Skip to content

Commit

Permalink
Adding the 2nd set of functionality and many more widgets
Browse files Browse the repository at this point in the history
  • Loading branch information
jamartinh committed Nov 26, 2015
1 parent 94324ed commit ada84a0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 21 deletions.
12 changes: 7 additions & 5 deletions orangecontrib/spark/utils/gui_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,19 @@ def update(self, values):
self.widget.setText(values)

def get_usable_value(self):
val = self.get_value()
if val=='None' or val=='' or val is None:
val = self.get_value().strip()
if val == 'None' or val == '' or val is None:
return None
if val in ('True', 'False'):
return bool(val)

try:
if float(val) == int(val):
return int(val)
else:
try:
if float(val) == int(val):
return int(val)
except ValueError:
return float(val)

except ValueError:
return val

Expand Down
27 changes: 11 additions & 16 deletions orangecontrib/spark/widgets/spark_ml_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,18 +416,18 @@ def set_data(self, data = None):
self.data = data
if self.data is not None:
self.in_df = self.data
#self.used_attrs.
#self.class_attrs = VariablesListItemModel()
#self.meta_attrs = VariablesListItemModel()
# self.used_attrs.
# self.class_attrs = VariablesListItemModel()
# self.meta_attrs = VariablesListItemModel()
self.available_attrs.extend(sorted(self.in_df.columns))

else:
self.data = None
self.in_df = None
#self.used_attrs = VariablesListItemModel()
#self.class_attrs = VariablesListItemModel()
#self.meta_attrs = VariablesListItemModel()
#self.available_attrs = VariablesListItemModel()
# self.used_attrs = VariablesListItemModel()
# self.class_attrs = VariablesListItemModel()
# self.meta_attrs = VariablesListItemModel()
# self.available_attrs = VariablesListItemModel()

def update_domain_role_hints(self):
""" Update the domain hints to be stored in the widgets settings.
Expand Down Expand Up @@ -569,16 +569,11 @@ def update_completer_prefix(self, filter):
def commit(self):
self.update_domain_role_hints()
if self.in_df is not None:
print(self.used_attrs)
print(self.class_attrs)
print(self.meta_attrs)

attributes = [att for att in self.used_attrs._list]
class_var = [var for var in self.class_attrs._list]
metas = [meta for meta in self.meta_attrs._list]
VA = VectorAssembler(inputCols = attributes, outputCol = 'features')
self.out_df = VA.transform(self.in_df)
print("class", class_var, type(class_var))
print("atributes", attributes)
if len(class_var):
self.out_df = self.out_df.withColumn('label', self.out_df[class_var[0]])
Expand All @@ -591,11 +586,11 @@ def reset(self):
if self.data is not None:
self.available_attrs.extend(sorted(self.in_df.columns))
else:
self.available_attrs = VariablesListItemModel()
self.available_attrs._list = []

self.used_attrs = VariablesListItemModel()
self.class_attrs = VariablesListItemModel()
self.meta_attrs = VariablesListItemModel()
self.used_attrs._list = []
self.class_attrs._list = []
self.meta_attrs._list = []
self.update_domain_role_hints()


Expand Down

0 comments on commit ada84a0

Please sign in to comment.