Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions openml/entities/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,7 @@ def decode_arff(fh):
return decode_arff(fh)

############################################################################
# pandas related stuff...
def get_dataset(self, target=None, include_row_id=False,
def get_dataset(self, target=None, target_dtype=int, include_row_id=False,
include_ignore_attributes=False,
return_categorical_indicator=False,
return_attribute_names=False):
Expand Down Expand Up @@ -176,7 +175,7 @@ def get_dataset(self, target=None, include_row_id=False,

try:
x = data[:,~targets]
y = data[:,targets].astype(np.int32)
y = data[:,targets].astype(target_dtype)

if len(y.shape) == 2 and y.shape[1] == 1:
y = y[:,0]
Expand All @@ -191,7 +190,7 @@ def get_dataset(self, target=None, include_row_id=False,
raise e

if scipy.sparse.issparse(y):
y = np.asarray(y.todense()).astype(np.int32).flatten()
y = np.asarray(y.todense()).astype(target_dtype).flatten()

rval.append(x)
rval.append(y)
Expand Down
9 changes: 8 additions & 1 deletion openml/entities/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,14 @@ def get_dataset(self):
def get_X_and_Y(self):
dataset = self.get_dataset()
# Replace with retrieve from cache
X_and_Y = dataset.get_dataset(target=self.target_feature)
if 'Supervised Classification'.lower() in self.task_type.lower():
target_dtype = int
elif 'Supervised Regression'.lower() in self.task_type.lower():
target_dtype = float
else:
raise NotImplementedError(self.task_type)
X_and_Y = dataset.get_dataset(target=self.target_feature,
target_dtype=target_dtype)
return X_and_Y

def evaluate(self, algo):
Expand Down