lrmodel=logreg_pipeline.fit(X_train_resh,y_train_resh)
lrmodel.write().overwrite().save("E:/strokestuff/strokelrpred")
lrmodel.save("E:/strokestuff/strokelrpred")
lrmodel is a pipeline, I want to save it, My aim is to save this model then load it to deploy it in Flutter. I have tried every solution I got, can someone help me with this?
You can use joblib to save your model in .joblib file:
import joblib
pipe_clf_params = {}
filename = 'E:/strokestuff/strokelrpred/strokelrpred.joblib'
pipe_clf_params['pipeline'] = lrmodel
joblib.dump(pipe_clf_params, filename)
Related
I have a PySpark code to train an H2o DRF model. I need to save this model to disk and then load it.
from pysparkling.ml import H2ODRF
drf = H2ODRF(featuresCols = predictors,
labelCol = response,
columnsToCategorical = [response])
I can not find any document on this so I am asking this question here.
I think the section of the docs on deploying pipeline models might be relevant: https://docs.h2o.ai/sparkling-water/2.3/latest-stable/doc/deployment/pysparkling_pipeline.html
Pipelines may not be what you're looking for depending on the use case.
Something like the following might work for your use case.
drf = H2ODRF(featuresCols = predictors,
labelCol = response,
columnsToCategorical = [response])
pipeline = Pipeline(stages=[drf])
model = pipeline.fit(data)
model.save("drf_model")
I created a new model and exported it as a .tflite model. Is there a way to use this model inside dart. When I input an array to the model, it make predictions and sends true or false. I want to do this inside dart. Which means, when I input a array to the model, I should be able to get true or false.
`
# Convert the model
converter = tf.lite.TFLiteConverter.from_saved_model('autoencoder') # path to the SavedModel directory
tflite_model = converter.convert()
# Save the model.
with open('model.tflite', 'wb') as f:
f.write(tflite_model)
`
This is the code I wrote and got .tflite file. How to use this file inside dart to make predictions to a given array.
I want to save the results of different runs in a compare runs experiment in Anylogic in an excel sheet or to some variable or output so that I use these values for some further calculations. How can I do that
Another flexible way of doing this is by writing the results to CSV. This should work for any kind of simulation or experiment with AnyLogic.
You'd have to import standard external libraries into the environment and add code to the experiment to be executed at the end of a simulation run.
Under imports section you could have this:
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.OutputStream;
import java.io.PrintStream;
First create a variable for the filename called csvFileName (you can call it whatever obviously). Then create a function in root called updateMyCSV() or something like that. This function would have a general structure of:
FileWriter pw = new FileWriter(csvFileName, true);
StringBuilder sb;
sb = new StringBuilder();
sb.append(<variablename>); sb.append(',');
Then repeat the above for each variable you want exported
Then finish the function with:
sb.append('\n');
pw.append(sb);
pw.flush();
pw.close();
Best use the build-in database and let it write to Excel at the end of all your runs.
Create a dbase table with columns such as "run_number", "replication_number", "experiment_parameter_X", "my_result_y". Each of your params on Main should get a column (at least those you vary) and each of the output values you are interested in.
This way, you can easily write your model results after each model run using the insertInto command (link).
Finally, just tick the "write to Excel" tickbox in your dbase, select the file and it will write all your raw results.
Also check the example models using the dbase, several use this approach
Noob to Gatling/Scala here.
This might be a bit of a silly question but I haven't been able to find an example of what I am trying to do.
I want to pass in things such as the baseURL, username and passwords for some of my calls. This would change from env to env, so I want to be able to change these values between the envs but still have the same tests in each.
I know we can feed in values but it appears that more for iterating over datasets and not so much for passing in the config values like I have.
Ideally I would like to house this information in a JSON file and not pass it in on the command line, but maybe thats not doable?
Any guidance on this would be awesome.
I have a similar setup and you can use pure scala here .In this scenario you can create an object called Config for eg
object Configuration { var INPUT_PROFILE_FILE_NAME = ""; }
This class can also read a file , I have the below code in the above object
val file = getClass.getResource("data/config.properties").getFile()
val prop = new Properties()
prop.load(new FileInputStream(file));
INPUT_PROFILE_FILE_NAME = prop.getProperty("inputProfileFileName")
Now you can import this object in Gattling Simulation File
val profileName= Configuration.INPUT_PROFILE_FILE_NAME ;
https://docs.scala-lang.org/tutorials/tour/singleton-objects.html.html
I am trying to convert the android tensorflow example provided in the tensorflow github into a Unity project. I have a .pb file for ssd_mobilenet_v1_android_export. But to use tensorflow models in Unity you have to have the model in a .bytes format. I can't figure out how to convert my .pb file to .bytes. I was going to use this code but I don't have any checkpoints for this graph, only the .pb file.
from tensorflow.python.tools import freeze_graph
freeze_graph.freeze_graph(input_graph = model_path +'/raw_graph_def.pb',
input_binary = True,
input_checkpoint = last_checkpoint,
output_node_names = "action",
output_graph = model_path +'/your_name_graph.bytes' ,
clear_devices = True, initializer_nodes = "",input_saver = "",
restore_op_name = "save/restore_all", filename_tensor_name = "save/Const:0")
Is there a simple way to do this conversion? Or a simple way to get a checkpoint for this model? It seems like this should be obvious but I can't figure it out. Thanks.
You can just switch extension from .pb to .bytes and for most cases this will work just fine. Check my TF Classify example for Unity.