Commit 4f77bd28 authored by Guolin Ke's avatar Guolin Ke
Browse files

update to v2.

parent 13d4581b
...@@ -6,21 +6,21 @@ import unittest ...@@ -6,21 +6,21 @@ import unittest
import lightgbm as lgb import lightgbm as lgb
import numpy as np import numpy as np
from sklearn.datasets import load_breast_cancer from sklearn.datasets import load_breast_cancer, dump_svmlight_file
from sklearn.model_selection import train_test_split from sklearn.model_selection import train_test_split
class TestBasic(unittest.TestCase): class TestBasic(unittest.TestCase):
def test(self): def test(self):
X_train, X_test, y_train, y_test = train_test_split(*load_breast_cancer(True), test_size=0.1, random_state=1) X_train, X_test, y_train, y_test = train_test_split(*load_breast_cancer(True), test_size=0.1, random_state=2)
train_data = lgb.Dataset(X_train, max_bin=255, label=y_train) train_data = lgb.Dataset(X_train, max_bin=255, label=y_train)
valid_data = train_data.create_valid(X_test, label=y_test) valid_data = train_data.create_valid(X_test, label=y_test)
params = { params = {
"objective": "binary", "objective": "binary",
"metric": "auc", "metric": "auc",
"min_data": 1, "min_data": 10,
"num_leaves": 15, "num_leaves": 15,
"verbose": -1 "verbose": -1
} }
...@@ -36,7 +36,7 @@ class TestBasic(unittest.TestCase): ...@@ -36,7 +36,7 @@ class TestBasic(unittest.TestCase):
with tempfile.NamedTemporaryFile() as f: with tempfile.NamedTemporaryFile() as f:
tname = f.name tname = f.name
with open(tname, "w+b") as f: with open(tname, "w+b") as f:
np.savetxt(f, X_test, delimiter=',') dump_svmlight_file(X_test, y_test, f)
pred_from_file = bst.predict(tname) pred_from_file = bst.predict(tname)
os.remove(tname) os.remove(tname)
self.assertEqual(len(pred_from_matr), len(pred_from_file)) self.assertEqual(len(pred_from_matr), len(pred_from_file))
...@@ -49,7 +49,7 @@ class TestBasic(unittest.TestCase): ...@@ -49,7 +49,7 @@ class TestBasic(unittest.TestCase):
for preds in zip(pred_from_matr, pred_from_model_file): for preds in zip(pred_from_matr, pred_from_model_file):
self.assertEqual(*preds) self.assertEqual(*preds)
# check pmml # check pmml
os.system('python ../../pmml/pmml.py model.txt') # os.system('python ../../pmml/pmml.py model.txt')
print("----------------------------------------------------------------------") print("----------------------------------------------------------------------")
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment