Pickle multiple machine learning model - artificial-intelligence

I have multilayer model consist of two models, kmeans and random forest classifier; that work inside single function.
My question is how to pickle both and keep them work in sequence???
Thanks in advance

Related

Kmeans as custom layer in functional model

We are planning to use kmeans to split our data and have 10 separate fully connected models to estimate results for each group from kmeans separately.
One obvious way is to have 10 separate tfjs models and separate kmeans on the beginning.
As tfjs supports functional models and custom layers. Alternative is to have kmeans as fist custom layer and then several dense layers connected to it. Is it possible to use existing layer API to receive 20 Tensors, perform kmeans and have 10 different set of 20 Tensors as output to next layers? Do you see any issues with this approach? Is there another alternative?
Kmeans is not yet implemented in tfjs. Had it been it couldn't have been considered as a layer itself. You can however create a two stage model in your class by supposing that you yourself you manage to have your own implementation of kmeans.
You'll simply have to pass the result of one model to the other using a conditional statement. The first model -kmeans - will output the class of the data and the second model - one out 10 - is chosen based on the output of the first model.
Having said that, all these can be done in one shot using either the sequential API tf.sequential or the functional one tf.model. There are kmeans implementation in js that will return js arrays as vectors. These arrays can be converted to tensors whose shape will determine the shape of the layers. Using FCNN , we can have an output for each kmeans class.

Is it possible to make two models in a single controller in mean stack?

I am new to the MEAN STACK and I am being asked to complete a project on the entry and exit of a user. The username of every user is stored in another collection. So, I want 2 models in a single module using the MEAN stack. Is it possible to make two models in a single module? I am using mongodb as the back end.
Kindly give a response. Thanks.
Yes you can call more than one Model & perform your queries,
Even you can try 2 collections in one collection.
Read About nested collections in MongoDB/Mongoose
http://mongoosejs.com/docs/subdocs.html

What Simulink input blocks do I need to to use to build such a system?

I am relatively new to Matlab/Simulink, and so thankful to have such a forum to place my questions, which might be a touch trivial to you guys. Thanking you for your time, here you go.
This is in creating a Simulink model.
My input is a speed and a load, which is variable. And for each input point, I need to get a pressure curve as the output (Pressure vs Crank angle), the data for which I have and will need to feed in. What sort of blocks will I need to use, and how do I integrate both the arrays?
Second question, which would be for a next step. I have 4 such data point sets (speed v load). Is there a way I could interpolate them to the whole speed/load map?
Like I mentioned before, really a novice here, so any help would be highly appreciated. Thanking you guys again. \m/
Regards,
Anirudh
If you have variables containing your data in MATLAB workspace, the best way to get them into Simulink is to use "From workspace" block. See documentation at http://www.mathworks.com/help/simulink/slref/fromworkspace.html. If your data is fixed and does not change over time use a Constant block. (http://www.mathworks.com/help/simulink/slref/constant.html). "From workspace" block also allows you to interpolate missing data.
Write the mathematical equations that model your system on paper, and implement them with Simulink blocks (best to start from higher order derivatives and integrate, rather than the other way round).
You may need/want to use a 1-D Lookup Table if you have some non-linear relationship in your model. Any data/variable that is in your MATLAB workspace is accessible from your Simulink model, e.g. to parameterise the blocks in your model. As already mentioned, you can use the From Workspace block to use your data as input(s) to the model.
You might also want to check the Getting Started guide for Simulink.

Actionscript folder system

Getting a bit stuck here on the idea...
I'm trying to create a flash card game / study material program where users are able to load lists of questions/answers. I want to organize the lists in a folder-like system. I imagine folders as arrays and the lists of questions and answers as text files.
My problem is that I know that with a single array, I can dynamically create an infinite amount of arrays... but how do I write data to the last array in the line? The idea is that the USER creates their own organization (dynamic, for different classes, subjects, etc)
I thought about something like myArray[i][j][k][l] but I don't know how to make it dynamic, such as if it was like myArray[3][4] has no subclasses or child arrays, or if [l] had 20 more subclasses/child arrays.
I was thinking about writing a function that has a loop that calls itself if there are children, but, I don't know how to make said unique for [i], [j], [k], etc.
Sorry if the information is a bit underwhelming, but I'm not sure how to express any more information.
Actionscript is object oriented and I will not try to create an array if it has to be dynamic. I will create an object called 'Questions' and will have the question text, text file location or whatever you want to maintain. I will create an ArrayCollection attribute called children with in the 'Question' class, which in turn is a list of Question objects. This way I can maintain hierarchy and add and remove children without much hassle.

Find() one of each matching field CakePHP

Trips hasMany Legs
Airports has no associations
How can I find the cheapest trip for each destination airport using CakePHP?
Right now, the only thing I can think of to do is to foreach through an array of airports. This would require hundreds of queries to the database (which I think is not the fastest way of doing it).
function getCheapestTrip($origin){
$airports=$this->Airport->getAirports();
foreach($airports as $airport):
$cheapest_flights=$this->Trip->find('first',
array(
'conditions'=>array('Leg.origin'=>$origin, 'MIN(Trip.price) as price'),
'fields'=>array('Trip.origin','price','Leg.destination','Leg.depart','Leg.arrive'),
'recursive'=>2,
));
endforeach;
}
}
Also, I think that this data type stuff should be in the model per CakePHP conventions (Fat models, skinny controllers). I read that to call a different model's function such as getAirports I can use loadModel but I found that in CakePHP's controller method section. How should one get another model's data/model function into anothers?
Thanks!
The answer to your second question, "How to load a model within another model?" can be found here.
If you're looking for a better algorithm rigth now I do not have the solution.
Mine is a design solution: basically you should add a field to your destination airport which will be updated every time you add a new flight so you have your information directly in your destination record.
This stands if I have understood your problem. I'm not english so I'm not familiar with the semantic of "leg" associated to a trip (to me it's a body part)
The problem you're solving is the Traveling Salesman Problem: http://en.wikipedia.org/wiki/Travelling_salesman_problem
From what I've read on how google maps does it, you'll want to precompute your most common routes and connections. Keep that precomputed info in a cheap cache (memcache prolly). Basically, you won't be able to recalculate each time, so calc a few common ones and build a precomputed cache.
WRT the algorithm, some google searching will be your friend for tips and tricks. This problem has been solved many times (none are exactly computationally efficient, which is why you should precompute and cache).

Resources