Code Monkey home page Code Monkey logo

Comments (21)

anubhavdikshit avatar anubhavdikshit commented on August 28, 2024 1

Guys,

You are all awesome, I cannot tell you how grateful I as well as many are
to you all. Beautiful written and beautifully explained!! The R community
is great because of people like you.. Thank you so much once again!

Thanks and Regards,
Anubhav Dikshit | Artoo | +91-8197401816

This e-mail and its attachment(s) contain information from Artoo IT
Solutions Private Limited which may be privileged or confidential. If you
are not the intended recipient, be aware that any disclosure, copying,
distribution, transmission or use of the contents of this e-mail and its
attachment(s) is prohibited and subject to legal penalties. If you received
this message in error you should notify the sender by returning the message
immediately and delete any copies from your system. Thank you for your
cooperation.

On Tue, Nov 8, 2016 at 7:46 PM, Devin Pastoor [email protected]
wrote:

ah yes of course - spacey of me - I discovered fiery from discussions
about future and have had this on my radar to use for my next REST api I
need to build.

Anyway, thanks for your work regardless!


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#6 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/ANZeWa72yQVyzrJXzSlH0yI-nuSR83s3ks5q8IQ4gaJpZM4KsRDY
.

from fiery.

thomasp85 avatar thomasp85 commented on August 28, 2024

I'm very happy for your impression.

I'm currently in a job transition and further my focus right now is on getting ggforce and ggraph out of the door. Once this has been done I'll begin to pic up the fiery ecosystem again, which has laid dormant the last couple of months... I hope that you can brace yourself with some time.

from fiery.

thomasp85 avatar thomasp85 commented on August 28, 2024

If you have a very specific problem or error I'll be happy to look at your code and give my opinion though...

from fiery.

anubhavdikshit avatar anubhavdikshit commented on August 28, 2024

Thanks for replying to me (impressive response speed!!) I completely
understand your situation, I would be waiting for you to work on Fiery,
thank you once again!!

Thanks and Regards,
Anubhav Dikshit | Artoo | +91-8197401816

This e-mail and its attachment(s) contain information from Artoo IT
Solutions Private Limited which may be privileged or confidential. If you
are not the intended recipient, be aware that any disclosure, copying,
distribution, transmission or use of the contents of this e-mail and its
attachment(s) is prohibited and subject to legal penalties. If you received
this message in error you should notify the sender by returning the message
immediately and delete any copies from your system. Thank you for your
cooperation.

On Tue, Nov 8, 2016 at 4:06 PM, Thomas Lin Pedersen <
[email protected]> wrote:

I'm very happy for your impression.

I'm currently in a job transition and further my focus right now is on
getting ggforce and ggraph out of the door. Once this has been done I'll
begin to pic up the fiery ecosystem again, which has laid dormant the last
couple of months... I hope that you can brace yourself with some time.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#6 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/ANZeWa7aSj7ObOXQ0tLcZOtX8dnLU1Naks5q8FC7gaJpZM4KsRDY
.

from fiery.

anubhavdikshit avatar anubhavdikshit commented on August 28, 2024

Thomas,

Please find the code that is slightly modified version of your code. My
model is C5.0 based decision tree, which uses multiple columns. Do you need
the model as well?

Thanks and Regards,
Anubhav Dikshit | Artoo | +91-8197401816

This e-mail and its attachment(s) contain information from Artoo IT
Solutions Private Limited which may be privileged or confidential. If you
are not the intended recipient, be aware that any disclosure, copying,
distribution, transmission or use of the contents of this e-mail and its
attachment(s) is prohibited and subject to legal penalties. If you received
this message in error you should notify the sender by returning the message
immediately and delete any copies from your system. Thank you for your
cooperation.

On Tue, Nov 8, 2016 at 4:07 PM, Thomas Lin Pedersen <
[email protected]> wrote:

If you have a very specific problem or error I'll be happy to look at your
code and give my opinion though...


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#6 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/ANZeWQxDwjZiEwrxPixgajeQgJ1xF762ks5q8FDigaJpZM4KsRDY
.

from fiery.

thomasp85 avatar thomasp85 commented on August 28, 2024

You cannot attach files to a GitHub issue email (I assume that this is what you tried)

from fiery.

anubhavdikshit avatar anubhavdikshit commented on August 28, 2024

Oops didnt know that, where can I send the code to you then. Its not on
Github as of it!

Thanks and Regards,
Anubhav Dikshit | Artoo | +91-8197401816

This e-mail and its attachment(s) contain information from Artoo IT
Solutions Private Limited which may be privileged or confidential. If you
are not the intended recipient, be aware that any disclosure, copying,
distribution, transmission or use of the contents of this e-mail and its
attachment(s) is prohibited and subject to legal penalties. If you received
this message in error you should notify the sender by returning the message
immediately and delete any copies from your system. Thank you for your
cooperation.

On Tue, Nov 8, 2016 at 4:40 PM, Thomas Lin Pedersen <
[email protected]> wrote:

You cannot attach files to a GitHub issue email (I assume that this is
what you tried)


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#6 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/ANZeWQVZjKegGY1I0-v4a9Xfp1baYhlcks5q8FixgaJpZM4KsRDY
.

from fiery.

thomasp85 avatar thomasp85 commented on August 28, 2024

Share it through dropbox etc... and paste a link here.

from fiery.

anubhavdikshit avatar anubhavdikshit commented on August 28, 2024

Here you go: https://www.dropbox.com/s/zld6f8gefbio29a/Bus_Asset_API.R?dl=0

Thanks and Regards,
Anubhav Dikshit | Artoo | +91-8197401816

This e-mail and its attachment(s) contain information from Artoo IT
Solutions Private Limited which may be privileged or confidential. If you
are not the intended recipient, be aware that any disclosure, copying,
distribution, transmission or use of the contents of this e-mail and its
attachment(s) is prohibited and subject to legal penalties. If you received
this message in error you should notify the sender by returning the message
immediately and delete any copies from your system. Thank you for your
cooperation.

On Tue, Nov 8, 2016 at 4:50 PM, Thomas Lin Pedersen <
[email protected]> wrote:

Share it through dropbox etc... and paste a link here.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#6 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/ANZeWTPum55L8YSaH0afnBY4xOBSTsXbks5q8FsLgaJpZM4KsRDY
.

from fiery.

thomasp85 avatar thomasp85 commented on August 28, 2024

Thanks - I'll have a look as time permits...

from fiery.

dpastoor avatar dpastoor commented on August 28, 2024

@anubhavdikshit I think your issue might be

res <- predict.C5.0(model, newdata = fromJSON(input), type = "class")

don't you want to only have grabbed the query string value to pass into the model, not the entire named list for

res <- predict.C5.0(model, 
-                   newdata = fromJSON(input),
                    type = "class")
res <- predict.C5.0(model,
+                     newdata = fromJSON(input$val), 
type = "class")

assuming input$val is a dataframe you want.

On the other hand, if input is a named list of columns, but you you want to pass a dataframe (per your code comments) into predict.C5.0 then you probably need do coerce to a dataframe rather than its list nature

...
newdata = as.data.frame(fromJSON(input))
...

from fiery.

anubhavdikshit avatar anubhavdikshit commented on August 28, 2024

Thank you so much, I will get back to you on this!!

Thanks and Regards,
Anubhav Dikshit | Artoo | +91-8197401816

This e-mail and its attachment(s) contain information from Artoo IT
Solutions Private Limited which may be privileged or confidential. If you
are not the intended recipient, be aware that any disclosure, copying,
distribution, transmission or use of the contents of this e-mail and its
attachment(s) is prohibited and subject to legal penalties. If you received
this message in error you should notify the sender by returning the message
immediately and delete any copies from your system. Thank you for your
cooperation.

On Tue, Nov 8, 2016 at 6:40 PM, Devin Pastoor [email protected]
wrote:

@anubhavdikshit https://github.com/anubhavdikshit I think your issue
might be

res <- predict.C5.0(model, newdata = fromJSON(input), type = "class")

don't you want to only have grabbed the query string value to pass into
the model, not the entire named list for

res <- predict.C5.0(model, - newdata = fromJSON(input),
type = "class")
res <- predict.C5.0(model,+ newdata = fromJSON(input$val),
type = "class")

assuming input$val is a dataframe you want.

On the other hand, if input is a named list of columns, but you you want
to pass a dataframe (per your code comments) into predict.C5.0 then you
probably need do coerce to a dataframe rather than its list nature

...
newdata = as.data.frame(fromJSON(input))
...


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#6 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/ANZeWXS22-360nTdxPR7AdWcx3PyFBzhks5q8HTYgaJpZM4KsRDY
.

from fiery.

anubhavdikshit avatar anubhavdikshit commented on August 28, 2024

Thomas,

This is what i am trying in terminal, curl 127.0.0.1:9123/predict.C5.0 -H
"Content-Type: application/json" -d '{"input" : [ {"age":26, "marital" :
"MARRIED"}]}'

This is what I get: Error : Argument 'txt' must be a JSON string, URL or
file.

Thanks and Regards,
Anubhav Dikshit | Artoo | +91-8197401816

This e-mail and its attachment(s) contain information from Artoo IT
Solutions Private Limited which may be privileged or confidential. If you
are not the intended recipient, be aware that any disclosure, copying,
distribution, transmission or use of the contents of this e-mail and its
attachment(s) is prohibited and subject to legal penalties. If you received
this message in error you should notify the sender by returning the message
immediately and delete any copies from your system. Thank you for your
cooperation.

On Tue, Nov 8, 2016 at 6:42 PM, Anubhav Dikshit [email protected] wrote:

Thank you so much, I will get back to you on this!!

Thanks and Regards,
Anubhav Dikshit | Artoo | +91-8197401816

This e-mail and its attachment(s) contain information from Artoo IT
Solutions Private Limited which may be privileged or confidential. If you
are not the intended recipient, be aware that any disclosure, copying,
distribution, transmission or use of the contents of this e-mail and its
attachment(s) is prohibited and subject to legal penalties. If you received
this message in error you should notify the sender by returning the message
immediately and delete any copies from your system. Thank you for your
cooperation.

On Tue, Nov 8, 2016 at 6:40 PM, Devin Pastoor [email protected]
wrote:

@anubhavdikshit https://github.com/anubhavdikshit I think your issue
might be

res <- predict.C5.0(model, newdata = fromJSON(input), type = "class")

don't you want to only have grabbed the query string value to pass into
the model, not the entire named list for

res <- predict.C5.0(model, - newdata = fromJSON(input),
type = "class")
res <- predict.C5.0(model,+ newdata = fromJSON(input$val),
type = "class")

assuming input$val is a dataframe you want.

On the other hand, if input is a named list of columns, but you you want
to pass a dataframe (per your code comments) into predict.C5.0 then you
probably need do coerce to a dataframe rather than its list nature

...
newdata = as.data.frame(fromJSON(input))
...


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#6 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/ANZeWXS22-360nTdxPR7AdWcx3PyFBzhks5q8HTYgaJpZM4KsRDY
.

from fiery.

anubhavdikshit avatar anubhavdikshit commented on August 28, 2024

Thomas,

I think without the model, its pretty hard to do anything, so please use
this model, https://www.dropbox.com/s/3lkwmnsnysikzcz/tv_model.rda?dl=0

and the predict function will be predict.gam(tv_model, newdata = newdata)

Hope this helps!

Thanks and Regards,
Anubhav Dikshit | Artoo | +91-8197401816

This e-mail and its attachment(s) contain information from Artoo IT
Solutions Private Limited which may be privileged or confidential. If you
are not the intended recipient, be aware that any disclosure, copying,
distribution, transmission or use of the contents of this e-mail and its
attachment(s) is prohibited and subject to legal penalties. If you received
this message in error you should notify the sender by returning the message
immediately and delete any copies from your system. Thank you for your
cooperation.

On Tue, Nov 8, 2016 at 6:52 PM, Anubhav Dikshit [email protected] wrote:

Thomas,

This is what i am trying in terminal, curl 127.0.0.1:9123/predict.C5.0 -H
"Content-Type: application/json" -d '{"input" : [ {"age":26, "marital" :
"MARRIED"}]}'

This is what I get: Error : Argument 'txt' must be a JSON string, URL or
file.

Thanks and Regards,
Anubhav Dikshit | Artoo | +91-8197401816

This e-mail and its attachment(s) contain information from Artoo IT
Solutions Private Limited which may be privileged or confidential. If you
are not the intended recipient, be aware that any disclosure, copying,
distribution, transmission or use of the contents of this e-mail and its
attachment(s) is prohibited and subject to legal penalties. If you received
this message in error you should notify the sender by returning the message
immediately and delete any copies from your system. Thank you for your
cooperation.

On Tue, Nov 8, 2016 at 6:42 PM, Anubhav Dikshit [email protected] wrote:

Thank you so much, I will get back to you on this!!

Thanks and Regards,
Anubhav Dikshit | Artoo | +91-8197401816

This e-mail and its attachment(s) contain information from Artoo IT
Solutions Private Limited which may be privileged or confidential. If you
are not the intended recipient, be aware that any disclosure, copying,
distribution, transmission or use of the contents of this e-mail and its
attachment(s) is prohibited and subject to legal penalties. If you received
this message in error you should notify the sender by returning the message
immediately and delete any copies from your system. Thank you for your
cooperation.

On Tue, Nov 8, 2016 at 6:40 PM, Devin Pastoor [email protected]
wrote:

@anubhavdikshit https://github.com/anubhavdikshit I think your issue
might be

res <- predict.C5.0(model, newdata = fromJSON(input), type = "class")

don't you want to only have grabbed the query string value to pass into
the model, not the entire named list for

res <- predict.C5.0(model, - newdata = fromJSON(input),
type = "class")
res <- predict.C5.0(model,+ newdata = fromJSON(input$val),
type = "class")

assuming input$val is a dataframe you want.

On the other hand, if input is a named list of columns, but you you want
to pass a dataframe (per your code comments) into predict.C5.0 then you
probably need do coerce to a dataframe rather than its list nature

...
newdata = as.data.frame(fromJSON(input))
...


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#6 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ANZeWXS22-360nTdxPR7AdWcx3PyFBzhks5q8HTYgaJpZM4KsRDY
.

from fiery.

dpastoor avatar dpastoor commented on August 28, 2024

ohh @anubhavdikshit you are trying to pass the json as data, @thomasp85 's example is passing it around as a query string

for example

http://127.0.0.1:9123/predict?val=-1.5

the breakdown is:

  • predict is the ROUTE
  • ? delineates that anything after will be query parameters

note, query parameters are separated by &

so in your case, you might do:

curl 127.0.0.1:9123/predict?age=26&marital=MARRIED

then when you parse the query string you'll get a list like

input <- list(age = "26", marital = "MARRIED") # what you'd get from parseQueryParams()
so you will need to convert age to numeric, and perhaps convert to a dataframe while you're at it

library(dplyr)
query_df <- as.data.frame(input) %>% mutate(age = as.numeric(age)
....
predict.gam(tv_model, newdata = query_df,...)

from fiery.

anubhavdikshit avatar anubhavdikshit commented on August 28, 2024

@devin Things make a little more sense now, I have one follow up question,
in case I use a different technique, why is the syntax in curl not changing
that is

why is it still _curl _127.0.0.1:9123/predict?age=26&marital=MARRIED
http://127.0.0.1:9123/predict?age=26&marital=MARRIED

and not *curl *

127.0.0.1:9123/predict.gam?age=26&marital=MARRIED
http://127.0.0.1:9123/predict?age=26&marital=MARRIED

And how do i just send a JSON while curl? that is

curl 127.0.0.1:9123/predict.C5.0 http://127.0.0.1:9123/predict.C5.0 -H
"Content-Type: application/json" -d '{"input" : [ {"age":26, "marital" :
"MARRIED"}]}'

Thanks and Regards,
Anubhav Dikshit | Artoo | +91-8197401816

This e-mail and its attachment(s) contain information from Artoo IT
Solutions Private Limited which may be privileged or confidential. If you
are not the intended recipient, be aware that any disclosure, copying,
distribution, transmission or use of the contents of this e-mail and its
attachment(s) is prohibited and subject to legal penalties. If you received
this message in error you should notify the sender by returning the message
immediately and delete any copies from your system. Thank you for your
cooperation.

On Tue, Nov 8, 2016 at 7:07 PM, Devin Pastoor [email protected]
wrote:

ohh @anubhavdikshit https://github.com/anubhavdikshit you are trying to
pass the json as data, @thomasp85 https://github.com/thomasp85 's
example is passing it around as a query string

for example

http://127.0.0.1:9123/predict?val=-1.5

the breakdown is:

  • predict is the ROUTE
  • ? delineates that anything after will be query parameters

note, query parameters are separated by &

so in your case, you might do:

curl 127.0.0.1:9123/predict?age=26&marital=MARRIED

then when you parse the query string you'll get a list like

input <- list(age = "26", marital = "MARRIED") # what you'd get from
parseQueryParams()
so you will need to convert age to numeric, and perhaps convert to a
dataframe while you're at it

library(dplyr)
query_df <- as.data.frame(input) %>% mutate(age = as.numeric(age)
....
predict.gam(tv_model, newdata = query_df,...)


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#6 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/ANZeWY2lUb_PYtvzvuGSijXWDdJ-CsuPks5q8HszgaJpZM4KsRDY
.

from fiery.

dpastoor avatar dpastoor commented on August 28, 2024

so there are two parts to this answer. First, purely from a naming perspective, the route name is arbitrarily established. This gets a little into API design, but you need to decide if you want your users being explicit about what they are hitting, eg .../predict_gam?<params> or more generic .../predict?<params where you then implement the logic of understanding what you need.

For example, you could have a model_type query param

/predict?model_type=GAM&<morevalues>

then you might have more logic

query  <- get("QUERY_STRING", envir=request)

# handy helper function from the Shiny folks
input <- shiny::parseQueryString(query)

if (input$model_type == "GAM") {
 predict.gam(....)
} else if {
....
}

the predict isn't a magical keyword or anything, you can see in the example

path <- get("PATH_INFO", envir=request)
  if (path == "/info") {
....
 } else if (grepl("^/predict", path)) {
....
}

In this case, the logic is saying if there is a query along the route that starts with the word predict, apply the following logic

You could just as easily change the route to any wording you'd like.

Finally, in sending JSON, I haven't looked into directly how fiery stores data from the response object, however if it is simple values, I would suggest just sending them as query strings.

Use https://insomnia.rest/ (its free!) and you can build up Params very easily so you don't have to type them in manually each time

for example:

image

from fiery.

thomasp85 avatar thomasp85 commented on August 28, 2024

@dpastoor Thanks for chiming in here! Ive got nothing else to really add...

from fiery.

dpastoor avatar dpastoor commented on August 28, 2024

@thomasp85 np, your future package has already saved me untold hours of work so want to give back where I can!

Also when you get some breathing room I'd be interested in helping out with the routr addition some, so feel free to ping me any time.

from fiery.

thomasp85 avatar thomasp85 commented on August 28, 2024

I will keep that in mind - thanks

but future is the work of @HenrikBengtsson so credit goes to him for that one - I was just one of the first to pick it up :-)

from fiery.

dpastoor avatar dpastoor commented on August 28, 2024

ah yes of course - spacey of me - I discovered fiery from discussions about future and have had this on my radar to use for my next REST api I need to build.

Anyway, thanks for your work regardless!

from fiery.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.