Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need an example with data and labels #2

Open
mytarmail opened this issue Dec 25, 2022 · 0 comments
Open

Need an example with data and labels #2

mytarmail opened this issue Dec 25, 2022 · 0 comments

Comments

@mytarmail
Copy link

Hello, I'm a bit confused with the labels, I don't understand how to put them correctly in my data.

I have sample data

fu <- function(){
size <- sample(10:30,1)
let <- LETTERS[sample(1:26,size = size,replace = T)]
mu <- make.unique(let,sep = "_")

c(  paste0("__label__",sample(1:2,1))  ,  mu)
}

li <- list()
for(i in 1:20) li[[i]] <- fu()

li2 <- lapply(li ,function(x) paste(x,collapse = " "))

head(li2)

the result is

[[1]]
[1] "__label__2 Y W Y_1 Y_2 E Z F N E_1 Q"

[[2]]
[1] "__label__1 N A I T D X E M Z F J V I_1 Y Q B J_1 R Y_1 Q_1 C U H R_1 Y_2 D_1 C_1 K"

[[3]]
[1] "__label__1 V F R B E R_1 M I U L Q C D K D_1 M_1 A M_2 A_1 M_3 S R_2 F_1 Z N A_2 E_1 M_4 G"

[[4]]
[1] "__label__2 O K D K_1 C D_1 J L Q F Y N Q_1 A Y_1 F_1 M V D_2"

save data

way <- "C:\...........\text.txt"
for(i in 1:length(li2))  write.table(x = li2[[i]] , file = way,append = T,col.names = F,row.names = F)

train model

library("fastTextR")
cntrl <- ft_control(word_vec_size = 10L, learning_rate = 0.1, max_len_ngram = 2L, 
                    min_count = 1L, nbuckets = 100000L, epoch = 5L, nthreads = 4L)
model <- ft_train(file = way, method = "supervised", control = cntrl)
model

model have no labels

fastText "supervised" model: 
   443 tokens, 90 words, 0 labels 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant