LightGBM icon indicating copy to clipboard operation
LightGBM copied to clipboard

Fatal Error: Tree model string format error

Open Soledad89 opened this issue 9 years ago • 8 comments

Has anybody encountered this error: Met Exceptions: Tree model string format error

I found that the model (LightGBM_model.txt) I have trained contains some codes as below:

num_leaves=1 split_feature= split_gain= threshold= decision_type= left_child= right_child= leaf_parent=-1 leaf_value=0 leaf_count=0 internal_value= internal_count= shrinkage=1

That's the bad boy. How to solve this kind of problem during training process? Thanks so much.

Soledad89 avatar Apr 22 '17 09:04 Soledad89

How do you train this model? python/R or cli? can you paste the full model file?

guolinke avatar Apr 22 '17 09:04 guolinke

@guolinke I just run the multiclass_class example with my own datasets, that has 18 classes and 50-dimention feature vector

# task type, support train and predict
task = train

# boosting type, support gbdt for now, alias: boosting, boost
boosting_type = gbdt

# application type, support following application
# regression , regression task
# binary , binary classification task
# lambdarank , lambdarank task
# multiclass
# alias: application, app
objective = multiclass

# eval metrics, support multi metric, delimite by ',' , support following metrics
# l1 
# l2 , default metric for regression
# ndcg , default metric for lambdarank
# auc 
# binary_logloss , default metric for binary
# binary_error
# multi_logloss
# multi_error
metric = multi_logloss

# number of class, for multiclass classification
num_class = 18

# frequence for metric output
metric_freq = 1

# true if need output metric for training data, alias: tranining_metric, train_metric
is_training_metric = true

# number of bins for feature bucket, 255 is a recommend setting, it can save memories, and also has good accuracy. 
max_bin = 255

# training data
# if exsting weight file, should name to "regression.train.weight"
# alias: train_data, train
data = multiclass.train

# valid data
valid_data = multiclass.test

# round for early stopping
early_stopping = 32

# number of trees(iterations), alias: num_tree, num_iteration, num_iterations, num_round, num_rounds
num_trees = 6400

# shrinkage rate , alias: shrinkage_rate
learning_rate = 0.05

# number of leaves for one tree, alias: num_leaf
num_leaves = 128

Soledad89 avatar Apr 24 '17 01:04 Soledad89

@Soledad89 , could you also share your training samples snippet?

chivee avatar Apr 24 '17 01:04 chivee

@chivee Of course yes.

2	-0.998034765141	-0.997706683756	-0.997314689194	-0.9981045614	-0.997629411465	-0.997813119594	-0.999393269667	-0.999013981692	-0.999197535788	-0.999796847852	-0.973528427146	-0.972987702038	-0.972251760183	-0.986813828764	-0.985929265736	-0.989343602974	-0.999619952868	-0.999139498859	-0.998952794858	-0.999572947562	-0.325514941145	0.153019787298	0.42280849477	0.581581249155	0.633799891812	0.521182652645	-0.270423705964	-0.205594218392	-0.587916320576	-0.990597605012	0.0421030110615	0.482631193353	0.774933478788	0.850205908371	0.935949581982	0.950049092198	-0.256683320968	-0.028672272683	-0.287016060665	-0.902583934781	-0.96366088554	-0.810406279636	-0.702659786771	-0.212641054104	-0.339831867621	-0.726196570603	-0.202525470066	-0.331472015525	-0.876332185002	-0.964340924203
3	-0.968713194268	-0.967523066378	-0.966454432214	-0.982745321757	-0.981869484474	-0.987012732186	-0.999578234816	-0.99926941828	-0.999354599343	-0.999813132863	-0.419471484792	-0.418186816554	-0.417099974939	-0.704764290359	-0.703965172059	-0.802370795023	-0.999993085125	-0.999987987943	-0.999988885474	-0.999996916191	-0.0443317570158	0.34915438745	0.655670499293	0.576077969	0.809692729985	0.870883643859	-0.490554318666	-0.172811882427	-0.220984559223	-0.766290715764	-0.0158620682162	0.370899761232	0.675948034777	0.701242095002	0.806455334871	0.710285625362	-0.147313286541	0.343206519509	0.294295055806	-0.575232762198	-0.982143442627	-0.982212203345	-0.976887006792	-0.994005487711	-0.977772241858	-0.951751530691	-0.997804877283	-0.98040291421	-0.955115621008	-0.965338437282
6	-0.992591348142	-0.976423897467	-0.950090779449	-0.949054225517	-0.909602884616	-0.883030880974	-0.969465093935	-0.937088288507	-0.932012070455	-0.973846948348	-0.991161678347	-0.9900767078	-0.985411363793	-0.993544986283	-0.98492197848	-0.973494762898	-0.999127775975	-0.993299849009	-0.983736599179	-0.987928807118	-0.818107519384	-0.816720444336	-0.81573837845	-0.903293636913	-0.902758888102	-0.93094573081	-0.999979924747	-0.99997087571	-0.999978929927	-0.999996453539	0.0491221588525	0.558536892529	0.920938458589	0.961839106659	0.968182427178	0.787485930102	-0.0327539647831	0.460598300324	0.394319042074	-0.5543609606	-0.963686673919	-0.879718841947	-0.831522800027	-0.537922722477	-0.632968397997	-0.87435548232	-0.532848651084	-0.62974107448	-0.947658405355	-0.971689871776
8	-0.962706421755	-0.962513197145	-0.962296953644	-0.981752413113	-0.981580390215	-0.987679757169	-0.999998405072	-0.999996186055	-0.999995271706	-0.99999788899	-0.152433439985	0.352271295228	0.722126006756	0.700069112142	0.923383019876	0.96722741512	-0.188065017871	0.238969751194	0.190109897713	-0.615786028593	-0.71776622776	-0.666520442654	-0.63514392976	-0.742572022475	-0.728497197389	-0.790685447625	-0.98183817228	-0.977514795468	-0.987267428152	-0.999015906566	-0.996829802544	-0.996766779992	-0.996218726896	-0.997958267809	-0.997173040157	-0.996913063201	-0.999996653903	-0.999872360414	-0.999624013563	-0.999666547144	-0.98422694957	-0.793063735152	-0.414908593023	-0.218480435487	0.165259865854	0.198201701912	-0.247029000159	0.137568128167	-0.0518752688574	-0.714254038228
12	-0.962266462331	-0.942764084878	-0.922728625326	-0.912384878866	-0.893404062737	-0.905811711623	-0.945220555013	-0.928130095151	-0.957321388086	-0.994702852455	-0.132818141918	0.416456673144	0.803224087495	0.801892627724	0.987068397583	0.986999828463	-0.0800331140152	0.388993566813	0.360827858554	-0.530095769727	-0.0250430166354	0.484732759447	0.830290918155	0.844200373005	0.973556182567	0.943493480796	-0.106179899405	0.325304939463	0.245590684513	-0.620360230463	0.000135971872172	0.518764687011	0.904767990138	0.95137010251	0.976128510427	0.800280154061	-0.0313981964597	0.477465566468	0.426085672833	-0.525847147235	-0.985689553687	-0.985688783148	-0.989722223799	-0.996564062331	-0.990682530181	-0.956583586166	-0.999999999455	-0.986992218888	-0.94831816322	-0.948321875174
16	-0.881202518069	-0.881139800621	-0.881064142816	-0.941808601346	-0.941718332212	-0.9615308626	-0.999759998541	-0.999670916784	-0.999791801368	-0.999968902259	-0.0812150928462	0.475255105033	0.843309047391	0.85141903908	0.988519765379	0.94708030913	-0.0111169506532	0.447402110696	0.395307611627	-0.538536922857	-0.0816065797724	0.386973942148	0.739443556136	0.725101093138	0.928908362987	0.943754336459	-0.233315135422	0.220016411861	0.200457759368	-0.588040259657	-0.963013165037	-0.959671773946	-0.956650896347	-0.969348697798	-0.967086985472	-0.972292995294	-0.997951268319	-0.996990134236	-0.997839687482	-0.999656856208	-0.982164461763	-0.980760604962	-0.988066755798	-0.993804520598	-0.993968766153	-0.963167657661	-0.999641226836	-0.990770824123	-0.952125878337	-0.947488045946
6	-0.975684293947	-0.972009887276	-0.964915540651	-0.981735556567	-0.973486213297	-0.971440534382	-0.999080400061	-0.996384792762	-0.993589944072	-0.996061831999	-0.981717883481	-0.973630882427	-0.960397645	-0.954674042125	-0.934132675691	-0.927763080884	-0.967709114544	-0.948309046848	-0.956488905399	-0.989785900123	-0.866673877407	-0.862147869908	-0.858105118343	-0.923032105149	-0.920111158209	-0.940570040721	-0.999650356661	-0.999386555526	-0.999434820662	-0.9998443271	-0.549984766385	-0.337376740055	-0.07508887081	-0.0497993811631	0.229497700835	0.339549745673	-0.561209681599	-0.25026300008	-0.29439611272	-0.789745960295	-0.963633650988	-0.864325409777	-0.738249289141	-0.477702621076	-0.427347073918	-0.61531494035	-0.475493050375	-0.424410603465	-0.754537113526	-0.993460399367
10	-0.417282636332	-0.0453515142183	0.280242982318	0.214436254845	0.509130540557	0.577537750385	-0.441779691965	-0.09648992617	-0.162869366956	-0.723504696229	-0.430711101051	0.0135580047269	0.377525214077	0.390467316695	0.648527726564	0.708882348143	-0.350213045977	-0.048169414112	-0.174151271138	-0.795252096024	-0.297967657086	0.168317998929	0.560196942946	0.592452616183	0.844755458606	0.90449468816	-0.206150481702	0.22047319995

Soledad89 avatar Apr 24 '17 02:04 Soledad89

@Soledad89 I mean the LightGBM_model.txt file.

guolinke avatar Apr 24 '17 02:04 guolinke

@Soledad89 BTW, it seems you didn't use the latest code. Can you try the latest code(master branch) ?

guolinke avatar Apr 24 '17 02:04 guolinke

@guolinke @chivee Great. While, I have tried the latest code and solved the issue. I suppose that it's my fault. The label should start from zero. That's the bad boy. Thanks soooo much for your kind reply.

Soledad89 avatar Apr 24 '17 12:04 Soledad89

This issue has been automatically locked since there has not been any recent activity since it was closed. To start a new related discussion, open a new issue at https://github.com/microsoft/LightGBM/issues including a reference to this.

github-actions[bot] avatar Aug 24 '23 02:08 github-actions[bot]