def _load(train_file, test_file, name): if not os.path.exists(train_file) or \ (test_file is not None and not os.path.exists(test_file)): raise IOError("Dataset missing! " + "Run 'make download-%s' at the project root." % name) if test_file: return load_svmlight_files((train_file, test_file)) else: X, y = load_svmlight_files((train_file, )) return X, y, None, None
def _load(train_file, test_file, name): if not os.path.exists(train_file) or \ (test_file is not None and not os.path.exists(test_file)): raise IOError("Dataset missing! " + "Run 'make download-%s' at the project root." % name) if test_file: return load_svmlight_files((train_file, test_file)) else: X, y = load_svmlight_files((train_file,)) return X, y, None, None
def test_load_svmlight_files(): X_train, y_train, X_test, y_test = load_svmlight_files([datafile] * 2, dtype=np.float32) assert_array_equal(X_train.toarray(), X_test.toarray()) assert_array_equal(y_train, y_test) assert_equal(X_train.dtype, np.float32) assert_equal(X_test.dtype, np.float32) X1, y1, X2, y2, X3, y3 = load_svmlight_files([datafile] * 3, dtype=np.float64) assert_equal(X1.dtype, X2.dtype) assert_equal(X2.dtype, X3.dtype) assert_equal(X3.dtype, np.float64)
def test_load_svmlight_files(): X_train, y_train, X_test, y_test = load_svmlight_files([datafile] * 2, dtype=np.float32) assert_array_equal(X_train.toarray(), X_test.toarray()) assert_array_equal(y_train, y_test) assert_equal(X_train.dtype, np.float32) assert_equal(X_test.dtype, np.float32) X1, y1, X2, y2, X3, y3 = load_svmlight_files([datafile] * 3, dtype=np.float64) assert_equal(X1.dtype, X2.dtype) assert_equal(X2.dtype, X3.dtype) assert_equal(X3.dtype, np.float64)
def test_load_invalid_file2(): load_svmlight_files([datafile, invalidfile, datafile])
def test_load_invalid_file2(): load_svmlight_files([datafile, invalidfile, datafile])