You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Great package! Thank you for creating this. I was testing out the MLPClassifier() model with this package--see the complete code below--and was getting an AttributeError: 'list' object has no attribute 'ndim' when I used the package as is. I added some code below to convert the model coefficient elements into numpy arrays and it seemed to work. Am I missing something? Was this an error with the package or was it an error in how I was using the package? Either way, thank you again. Note: I was using Python 3.7.4.
importnumpyasnpimportsklearn_jsonasskljsonfromsklearn.neural_networkimportMLPClassifierfromsklearnimportdatasets# Load datadf=datasets.load_iris()
X=df.datay=df.target# Instantiate and fit modelmodel_fit=MLPClassifier(solver='lbfgs', alpha=1e-5,
hidden_layer_sizes=(15,), random_state=1).fit(X, y)
file_name="model.json"# Convert model to jsonskljson.to_json(model_fit, file_name)
# Convert json back to modeldeserialized_model=skljson.from_json(file_name)
## THE MISSING PIECE: THE LISTS INSIDE COEFS_ NEED## TO BE CONVERTED TO ARRAYSfori, xinenumerate(deserialized_model.coefs_):
deserialized_model.coefs_[i] =np.array(x)
# This prediction should run if the code really worksdeserialized_model.predict(X)
The text was updated successfully, but these errors were encountered:
Hey thanks for the kind words and I'm glad you enjoy it.
Do the tests pass for you? If so, then it's probably not your fault and just something I missed. Feel free to make a PR with an updated MLP classifier test.
Thanks for consulting on this matter. There are three failing tests when I run pytest on the current codebase with my machine: test_mlp, test_svm, and test_svr. I am using Python 3.7.4, numpy 1.18.1, and scikit-learn 0.22. Perhaps this is an issue particular to one of these package versions.
Yes, it is likely the new scikit-learn version, as this was developed with 0.21.3. I'm not as active with this project right now and should update the readme to reflect as such. I welcome contributions, however!
Great package! Thank you for creating this. I was testing out the MLPClassifier() model with this package--see the complete code below--and was getting an
AttributeError: 'list' object has no attribute 'ndim'
when I used the package as is. I added some code below to convert the model coefficient elements into numpy arrays and it seemed to work. Am I missing something? Was this an error with the package or was it an error in how I was using the package? Either way, thank you again. Note: I was using Python 3.7.4.The text was updated successfully, but these errors were encountered: