Skip to main content

Posts

Showing posts from June, 2021

how to open .model model objects in python?

Introduction: A few days ago, I got a model called xyz.model. We got it from a client and I had no idea how to open it. And after searching a lot, I couldn't find out an useful answer though. That's why this article. What is the object? a .model model object is created on saving xgboost model from R, using xgboost::save() method. That is how it is created. Now as you may guess, using a R model in python we will have a problem. And you are right. In general the standard xgboost library will not be able to load according to  this github thread . What is the issue? Actually it is impossible to load a model from a buffer (e.g. bytestring) in Python, due to a bug where ctypes is used incorrectly to get a const char* pointer: >> > bst . load_model ( b'123' ) TypeError : underlying buffer is not writable Here's a short example of what it is basically trying to do: >> > b = b'123' >> > ( ctypes . c_char * 3 ). from_buf

How to download single file from github?

Problem: Often, you will need a single file to download from github, but you can't figure out how to do that. In such a case, a lot of people will suggest that you will need to download the whole repository. But that's not a useful suggestion and you know it. So what to do? Solution: In such a case, first click the view raw option in github ui. This will redirect into a new tab generally and show the rawgithubusercontent.com/... site and the raw content in that tab. Avoid this. Get this raw content in the same tab. This will create a similar rawgithubusercontent.com/... url.  Now, using this url, use curl <url> to fetch this content. This will download the raw content in your computer.  Installation (if needed): For linux and mac, you will have this curl installed by default. For windows, you need to install it if your version is not later than windows 10. To try out the installation see Testing your cURL installation below. [the following part is taken from z