Questions tagged [pickle]

An object serialization module for Python. Use this tag together with the Python tag for questions related to storing or loading objects with Pickle.

Pickle provides a powerful set of tools for serializing and de-serializing Python objects.

4130 questions
1
vote
1 answer

Python 3.9: unpickling of IsoCalendarDate data returns a tuple

Consider the following discussion / feature in Python3.9: https://bugs.python.org/issue24416 In short, it was decided that the result of datetime.date.isocalendar would be changed to a namedtuple instead of tuple. Now, I can see the benefit in doing…
W2a
  • 644
  • 7
  • 20
1
vote
1 answer

Is there a method to serialize a machine learning model in within tidymodels (similar to pickling a model in Python)?

I am aware that the in Python you can serialize a ML model using the pickle module; however, is there a method to do something similar in the tidymodel space? My goal would be to be able to save a trained model to be deployed later.
Moyo Ajayi
  • 13
  • 4
1
vote
2 answers

Pickle dump multiple variables and read them on aother file on another directory

How can I dump multiple python variables and load them in another file? the code I have now: EXP_load = pickle.load(open("data.dat", "rb")) if EXP_load == "0": EXP = str("0") Kills = str("0") Items = str("0") pickle.dump(EXP,…
MdeGraaff
  • 122
  • 9
1
vote
0 answers

How to save rgb and depth data from libfreenect2?

I'm using pickle to save rgb and depth frames received from kinect-v2 (libfreenect2), but it throws the following error: Exception has occurred: TypeError can't pickle _cffi_backend.__CDataGCP objects File…
paul-shuvo
  • 1,532
  • 2
  • 23
  • 35
1
vote
0 answers

Saving a DataFrame object on Google Colab and loading the pickle file on my local computer results in a recursion error

I was using google colab to train some XGB models and was saving the results in a pickle file after which I would load and read them on my local computer for analysis. This was working fine for the past few months till recently where I could no…
Lim Kaizhuo
  • 524
  • 2
  • 5
  • 14
1
vote
0 answers

Limitations of python pickle? Can it serialize anything?

I'm writting a little module that must be able to persist anything to disk. I don't know ahead of time what kind of data will be in a variable so, I need default functionality that can serialize ANYTHING to disk. I suppose pickle is the best thing…
Legit Stack
  • 1,998
  • 3
  • 24
  • 43
1
vote
1 answer

Python Anywhere - No module named 'sklearn.linear_model._stochastic_gradient'

I want to use the pickle module and serialize the model learned on my computer: pickle.dump(clf, open(os.path.join(dest, 'classifier.pkl'), 'wb'), protocol=4) When I open it on my computer as well, everything works fine: clf =…
Karol
  • 105
  • 8
1
vote
2 answers

Python Pickle Issue

We had given a task and for which we written below code, while executing it showing an error. Hence issue in pickle need help for . Please let us know where we went wrong in coding- import os import builtins import pickle import…
1
vote
1 answer

Load a scikit-learn pipeline containing a pre-trained Keras model from disk

I've built a scikit-learn pipeline which uses an LSTM Keras model (wrapped in a keras.wrappers.scikit_learn.KerasClassifier) as the last pipeline step. Once the pipeline finishes training I save the whole pipeline to disk (see below). I'm having…
Swazy
  • 298
  • 3
  • 9
1
vote
1 answer

Renaming the target variable's class names of trained Sklearn classifier mode

I have created a model that predicts the name of a flower based on its features using LinearSVC in sklearn and saved the model using pickle. for example my target variables are lily and rose - so given the features the model has the capability to…
Jithin P James
  • 508
  • 1
  • 5
  • 16
1
vote
1 answer

Retrieve all pickled data in a folder

I'm new to Python. I have matrices saved in a specific folder as .pkl. I would like to retrieve pickled data with a for loop over this folder. I also would like the new variable to have the same name as the file from which I'm reading the data. In…
Virginie
  • 113
  • 8
1
vote
2 answers

Store and retrieve pickled python objects to/from snowflake

as per question, I am trying to store picked python objects to snowflake, to get them back again at a later date. Help on this would be much appreciated: Snowflake table definition: CREATE OR REPLACE TABLE ..TESTING_MEMORY ( …
1
vote
3 answers

AttributeError when not trying to use any attribute

Good morning! I'm using a code (with python 3.8) that is running both in a local PC and in a ssh server. In one point, I'm loading data from a pickle using the next piece of code: from os.path import exists import _pickle as pickle def…
Á. Garzón
  • 157
  • 7
1
vote
0 answers

Pickling Networkx's edge_subgraph raises an error

I am trying to pickle networkx's edge_subgraph and I does not work. Here is the code import networkx as nx import pickle as pkl G = nx.binomial_graph(100, 0.1) significant_edges = [(u,v) for u,v in G.edges() if G.degree[u] == G.degree[v]] subgraph…
Tomáš Hons
  • 145
  • 7
1
vote
0 answers

How can I setup an API endpoint, load a model, and make a prediction?

I am trying to run this code (thanks A.B.) from flask import Flask, jsonify import pickle import pandas as pd import requests app = Flask(__name__) @app.route('/predict', methods=['POST']) def predict(): json_features = requests.json …
ASH
  • 15,523
  • 6
  • 50
  • 116
1 2 3
99
100