Coder Social home page Coder Social logo

Has ValueError "Must pass 2-d input" while Long Short Term Memory Classifier(Binary Classification) about network-intrusion-detection-using-machine-learning HOT 3 CLOSED

abhinav-bhardwaj avatar abhinav-bhardwaj commented on August 21, 2024
Has ValueError "Must pass 2-d input" while Long Short Term Memory Classifier(Binary Classification)

from network-intrusion-detection-using-machine-learning.

Comments (3)

abhinav-bhardwaj avatar abhinav-bhardwaj commented on August 21, 2024

Include the below code
X_test = X_test.to_numpy()
before executing this
x_test = np.reshape(X_test, (X_test.shape[0],X_test.shape[1],1))

This will fix the problem.

Closing the issue. Reopen if this issue arises again.

from network-intrusion-detection-using-machine-learning.

klcheung99 avatar klcheung99 commented on August 21, 2024

Abhinav, thank you so much!
Do you have LSTM Classifier (Multi-class Classification).
Moreover, I would want to use SHAP (SHapley Additive exPlanations), to explain the hidden layer and your model (KNN and LSTM), to see what features are the top important features while determining the result of model. however, there has some bugs.. I am so sorry to disturb you. but I spend a week to debug still got nothing. It will be great thankful if you have time to take a look! Thank you so much! Wish you have a nice weekend.

KNN SHAP explainer
`!pip install shap
import shap

knn_explainer = shap.KernelExplainer(knn.predict,X_test)
knn_shap_values = knn_explainer.shap_values(X_test)
shap.summary_plot(knn_shap_values, X_test)
shap.dependence_plot("intrusion", knn_shap_values, X_test)

shap.force_plot(knn_explainer.expected_value,knn_shap_values[10,:], X_test.iloc[10,:])
shap.force_plot(knn_explainer.expected_value, knn_shap_values, X_test)`

LSTM SHAP explainer
`import shap

explainer = shap.DeepExplainer(lstm, x_train)
shap_values = explainer.shap_values(x_test)
shap.initjs()`

from network-intrusion-detection-using-machine-learning.

abhinav-bhardwaj avatar abhinav-bhardwaj commented on August 21, 2024

@klcheung99 Thank you for mentioning this. At the moment I don't have LSTM for Multi-class but I will make sure to include that soon. Also, I will look into the SHAP issue.

from network-intrusion-detection-using-machine-learning.

Related Issues (2)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.