Write Data Command Files from model instance - pyomo

Given a Pyomo model that is fully specified, is it possible to write it's Set and Param components back to Data Command Files?
One use case would be to feed that data to another Pyomo model, or even load the Data Command Files into an existing AMPL toolchain to compare and debug models when porting from AMPL to Pyomo.

Related

weka say that my data set train and test set are not compatible

why weka say my train and test file is not compatible
I'm trying to test my model with new dataset in weka. I have done the same preprocessing step as i have done for building my model. I have all the attributes(train vs test dataset) in same order, same attribute names and data types. But still i'm not able to resolve the issue. Both of the files train and test seems to be similar but the weka explorer is giving me error saying Train and test set are not compatible. How to resolve this error?

How to use *.mbconfig files with mlnet CLI

I am looking to automate more of the auto-training that can be done via the Visual Studio GUI. The mlnet command line tool is useful, but doesn't allow specification of column types, and seems to default many of my numerical fields to "strings" rather than "single" when loading data from a CSV file (especially values such as '0.05663258').
Is there a way to pass a .mbconfig file to the mlnet command line tool (since these are just JSON files with a great deal more flexibility)? It looks like this might be a pending feature request, but the tool's documentation is a little inconsistent from source to source...
Alternatively, is there a way to specify column types (or default column types) in the CLI? I do see the command options to ignore columns, but nothing to control either default column datatypes, or datatypes for individual columns.
If you install the new ML.NET CLI (version 16.13 or up), then it will include a train command and you will use it like this...
mlnet train --training-config <mbconfig-name>
Note that the training data that was used to generate the "mbconfig" file will also need to be in the same directory.

save and load unserialized pytorch pretrained model

for normal saving and loading pytorch model is quite simple.
in python I can use torch.save(model, FilePath) and in c++torch::jit::load(FilePath). and the saved model and c++ load code can be placed in one directory. However, there is a limitation that binary file cannot be contained in the directory in the production mode (Please don't ask me why the binary file cannot be contained, I also wondering).
So, I want to know how to save the pytorch model from python without serializtion and load this model in c++. Is it possible?
Use the ONNX file format. Pytorch can output files in this format, and then you should be able to find a related library to load this in C++.

Load Pyomo data command files directly to Python data structures

Given a Pyomo model and corresponding data command file input.dat, I would like to verify the model I built with a 3rd party tool. To be more specific, it is a network flow model with the topology defined in the data command file. The strategy would then be to load the topology from that input.dat and use it as an input to the 3rd party tool.
The actual question: Is there a way to load the topology defined in the Pyomo input.dat directly into Python data structures (e.g. sets, dicts, etc.) instead of round tripping through Pyomo data structures (pyomo.environ.Set et al.) and then building the Python data structures from the Pyomo data structures - for the sake of convenience? Is there maybe an undocumented or unofficial internal API function that does this?
You might be able to do this using the DataPortal infrastructure in Pyomo. See the documentation here: https://pyomo.readthedocs.io/en/latest/working_abstractmodels/data/dataportals.html

Word2Vec model output types

When Word2Vec model is trained, there are three outputs created.
model
model.wv.syn0
model.syn1neg
I have a couple of questions regarding these models.
How are these outputs essentially different from each other?
Which model to look at if I want to access trained results?
Thanks in advance !
Those are 3 files created by the gensim Word2Vec .save() function. The model file is a Python pickle of the main model; the other files are some of the over-large numpy arrays stored separately for efficiency. The syn0 happens to contain the raw word vectors, and the syn1neg the model's internal weights – but neither are cleanly interpretable without the other data.
So, the only support for re-loading them is to use the matching .load() function, with all three available. A successful re-load() will result in a model object just like the one you save()d, and you'd access the results via that loaded object.
(If you only need the raw word-vectors, you can also use the .save_word2vec_format() method, which writes in a format compatible with the original Google-releases word2vec.c code. But that format has strictly less information that gensim's native save, so you'd only use it if you absolutely need to for compatibility with other software. Working with the gensim native files ensures you could always save the other format later, while you can't go the other way.)