Debugging Numpy VisibleDeprecationWarning (ndarray from ragged nested sequences)

With a function that creates a ragged array: In [60]: def foo(): …: print(‘one’) …: x = np.array([[1],[1,2]]) …: return x …: In [61]: foo() one /usr/local/bin/ipython3:3: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, … Read more

using Subprocess to avoid long-running task from disconnecting bot?

praw relies on the requests library, which is synchronous meaning that the code is blocking. This can cause your bot to freeze if the blocking code takes too long to execute. To get around this, a separate thread can be created that handles the blocking code. Below is an example of this. Note how blocking_function … Read more

Saving StandardScaler() model for use on new datasets

you could use joblib dump function to save the standard scaler model. Here’s a complete example for reference. from sklearn.preprocessing import StandardScaler from sklearn.model_selection import train_test_split from sklearn.datasets import load_iris data, target = load_iris(return_X_y=True) X_train, X_test, y_train, y_test = train_test_split(data, target) sc = StandardScaler() X_train_std = sc.fit_transform(X_train) if you want to save the sc standardscaller … Read more