Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
tianlh
LightGBM-DCU
Commits
03ba7304
Commit
03ba7304
authored
Jun 17, 2017
by
Szilard Pafka
Committed by
Guolin Ke
Jun 17, 2017
Browse files
fix bug (#630)
parent
6fa51478
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
22 deletions
+22
-22
R-package/R/lgb.prepare_rules.R
R-package/R/lgb.prepare_rules.R
+11
-11
R-package/R/lgb.prepare_rules2.R
R-package/R/lgb.prepare_rules2.R
+11
-11
No files found.
R-package/R/lgb.prepare_rules.R
View file @
03ba7304
...
@@ -92,7 +92,7 @@ lgb.prepare_rules <- function(data, rules = NULL) {
...
@@ -92,7 +92,7 @@ lgb.prepare_rules <- function(data, rules = NULL) {
# Map characters/factors
# Map characters/factors
is_fix
<-
which
(
list_classes
%in%
c
(
"character"
,
"factor"
))
is_fix
<-
which
(
list_classes
%in%
c
(
"character"
,
"factor"
))
rules
et
<-
list
()
rules
<-
list
()
# Need to create rules?
# Need to create rules?
if
(
length
(
is_fix
)
>
0
)
{
if
(
length
(
is_fix
)
>
0
)
{
...
@@ -113,13 +113,13 @@ lgb.prepare_rules <- function(data, rules = NULL) {
...
@@ -113,13 +113,13 @@ lgb.prepare_rules <- function(data, rules = NULL) {
mini_numeric
<-
as.numeric
(
mini_unique
)
# No respect of ordinality
mini_numeric
<-
as.numeric
(
mini_unique
)
# No respect of ordinality
}
}
# Create rules
et
# Create rules
indexed
<-
colnames
(
data
)[
i
]
# Index value
indexed
<-
colnames
(
data
)[
i
]
# Index value
rules
et
[[
indexed
]]
<-
mini_numeric
# Numeric content
rules
[[
indexed
]]
<-
mini_numeric
# Numeric content
names
(
rules
et
[[
indexed
]])
<-
mini_unique
# Character equivalent
names
(
rules
[[
indexed
]])
<-
mini_unique
# Character equivalent
# Apply to real data column
# Apply to real data column
set
(
data
,
j
=
i
,
value
=
unname
(
rules
et
[[
indexed
]][
mini_data
]))
set
(
data
,
j
=
i
,
value
=
unname
(
rules
[[
indexed
]][
mini_data
]))
}
}
...
@@ -150,7 +150,7 @@ lgb.prepare_rules <- function(data, rules = NULL) {
...
@@ -150,7 +150,7 @@ lgb.prepare_rules <- function(data, rules = NULL) {
# Map characters/factors
# Map characters/factors
is_fix
<-
which
(
list_classes
%in%
c
(
"character"
,
"factor"
))
is_fix
<-
which
(
list_classes
%in%
c
(
"character"
,
"factor"
))
rules
et
<-
list
()
rules
<-
list
()
# Need to create rules?
# Need to create rules?
if
(
length
(
is_fix
)
>
0
)
{
if
(
length
(
is_fix
)
>
0
)
{
...
@@ -171,13 +171,13 @@ lgb.prepare_rules <- function(data, rules = NULL) {
...
@@ -171,13 +171,13 @@ lgb.prepare_rules <- function(data, rules = NULL) {
mini_numeric
<-
as.numeric
(
mini_unique
)
# No respect of ordinality
mini_numeric
<-
as.numeric
(
mini_unique
)
# No respect of ordinality
}
}
# Create rules
et
# Create rules
indexed
<-
colnames
(
data
)[
i
]
# Index value
indexed
<-
colnames
(
data
)[
i
]
# Index value
rules
et
[[
indexed
]]
<-
mini_numeric
# Numeric content
rules
[[
indexed
]]
<-
mini_numeric
# Numeric content
names
(
rules
et
[[
indexed
]])
<-
mini_unique
# Character equivalent
names
(
rules
[[
indexed
]])
<-
mini_unique
# Character equivalent
# Apply to real data column
# Apply to real data column
data
[[
i
]]
<-
unname
(
rules
et
[[
indexed
]][
mini_data
])
data
[[
i
]]
<-
unname
(
rules
[[
indexed
]][
mini_data
])
}
}
...
@@ -194,6 +194,6 @@ lgb.prepare_rules <- function(data, rules = NULL) {
...
@@ -194,6 +194,6 @@ lgb.prepare_rules <- function(data, rules = NULL) {
}
}
return
(
list
(
data
=
data
,
rules
=
rules
et
))
return
(
list
(
data
=
data
,
rules
=
rules
))
}
}
R-package/R/lgb.prepare_rules2.R
View file @
03ba7304
...
@@ -92,7 +92,7 @@ lgb.prepare_rules2 <- function(data, rules = NULL) {
...
@@ -92,7 +92,7 @@ lgb.prepare_rules2 <- function(data, rules = NULL) {
# Map characters/factors
# Map characters/factors
is_fix
<-
which
(
list_classes
%in%
c
(
"character"
,
"factor"
))
is_fix
<-
which
(
list_classes
%in%
c
(
"character"
,
"factor"
))
rules
et
<-
list
()
rules
<-
list
()
# Need to create rules?
# Need to create rules?
if
(
length
(
is_fix
)
>
0
)
{
if
(
length
(
is_fix
)
>
0
)
{
...
@@ -112,13 +112,13 @@ lgb.prepare_rules2 <- function(data, rules = NULL) {
...
@@ -112,13 +112,13 @@ lgb.prepare_rules2 <- function(data, rules = NULL) {
mini_numeric
<-
as.integer
(
mini_unique
)
# No respect of ordinality
mini_numeric
<-
as.integer
(
mini_unique
)
# No respect of ordinality
}
}
# Create rules
et
# Create rules
indexed
<-
colnames
(
data
)[
i
]
# Index value
indexed
<-
colnames
(
data
)[
i
]
# Index value
rules
et
[[
indexed
]]
<-
mini_numeric
# Numeric content
rules
[[
indexed
]]
<-
mini_numeric
# Numeric content
names
(
rules
et
[[
indexed
]])
<-
mini_unique
# Character equivalent
names
(
rules
[[
indexed
]])
<-
mini_unique
# Character equivalent
# Apply to real data column
# Apply to real data column
set
(
data
,
j
=
i
,
value
=
unname
(
rules
et
[[
indexed
]][
mini_data
]))
set
(
data
,
j
=
i
,
value
=
unname
(
rules
[[
indexed
]][
mini_data
]))
}
}
...
@@ -149,7 +149,7 @@ lgb.prepare_rules2 <- function(data, rules = NULL) {
...
@@ -149,7 +149,7 @@ lgb.prepare_rules2 <- function(data, rules = NULL) {
# Map characters/factors
# Map characters/factors
is_fix
<-
which
(
list_classes
%in%
c
(
"character"
,
"factor"
))
is_fix
<-
which
(
list_classes
%in%
c
(
"character"
,
"factor"
))
rules
et
<-
list
()
rules
<-
list
()
# Need to create rules?
# Need to create rules?
if
(
length
(
is_fix
)
>
0
)
{
if
(
length
(
is_fix
)
>
0
)
{
...
@@ -169,13 +169,13 @@ lgb.prepare_rules2 <- function(data, rules = NULL) {
...
@@ -169,13 +169,13 @@ lgb.prepare_rules2 <- function(data, rules = NULL) {
mini_numeric
<-
as.integer
(
mini_unique
)
# No respect of ordinality
mini_numeric
<-
as.integer
(
mini_unique
)
# No respect of ordinality
}
}
# Create rules
et
# Create rules
indexed
<-
colnames
(
data
)[
i
]
# Index value
indexed
<-
colnames
(
data
)[
i
]
# Index value
rules
et
[[
indexed
]]
<-
mini_numeric
# Numeric content
rules
[[
indexed
]]
<-
mini_numeric
# Numeric content
names
(
rules
et
[[
indexed
]])
<-
mini_unique
# Character equivalent
names
(
rules
[[
indexed
]])
<-
mini_unique
# Character equivalent
# Apply to real data column
# Apply to real data column
data
[[
i
]]
<-
unname
(
rules
et
[[
indexed
]][
mini_data
])
data
[[
i
]]
<-
unname
(
rules
[[
indexed
]][
mini_data
])
}
}
...
@@ -192,6 +192,6 @@ lgb.prepare_rules2 <- function(data, rules = NULL) {
...
@@ -192,6 +192,6 @@ lgb.prepare_rules2 <- function(data, rules = NULL) {
}
}
return
(
list
(
data
=
data
,
rules
=
rules
et
))
return
(
list
(
data
=
data
,
rules
=
rules
))
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment