Open easyans opened 8 months ago
ModuleNotFoundError Traceback (most recent call last)
File [c:\Users\AAkash\Desktop\acuda\Explainable-AI-for-Early-Detection-and-Severity-Assessment-of-Alzheimer-s-Disease\lime.py:7](file:///C:/Users/AAkash/Desktop/acuda/Explainable-AI-for-Early-Detection-and-Severity-Assessment-of-Alzheimer-s-Disease/lime.py:7)
[5](file:///C:/Users/AAkash/Desktop/acuda/Explainable-AI-for-Early-Detection-and-Severity-Assessment-of-Alzheimer-s-Disease/lime.py:5) from interpret.blackbox import LimeTabular
[6](file:///C:/Users/AAkash/Desktop/acuda/Explainable-AI-for-Early-Detection-and-Severity-Assessment-of-Alzheimer-s-Disease/lime.py:6) from interpret import show
----> [7](file:///C:/Users/AAkash/Desktop/acuda/Explainable-AI-for-Early-Detection-and-Severity-Assessment-of-Alzheimer-s-Disease/lime.py:7) from lime.lime_tabular import LimeTabularExplainer
File [c:\Users\AAkash\Desktop\acuda\Explainable-AI-for-Early-Detection-and-Severity-Assessment-of-Alzheimer-s-Disease\lime.py:7](file:///C:/Users/AAkash/Desktop/acuda/Explainable-AI-for-Early-Detection-and-Severity-Assessment-of-Alzheimer-s-Disease/lime.py:7)
[5](file:///C:/Users/AAkash/Desktop/acuda/Explainable-AI-for-Early-Detection-and-Severity-Assessment-of-Alzheimer-s-Disease/lime.py:5) from interpret.blackbox import LimeTabular
[6](file:///C:/Users/AAkash/Desktop/acuda/Explainable-AI-for-Early-Detection-and-Severity-Assessment-of-Alzheimer-s-Disease/lime.py:6) from interpret import show
----> [7](file:///C:/Users/AAkash/Desktop/acuda/Explainable-AI-for-Early-Detection-and-Severity-Assessment-of-Alzheimer-s-Disease/lime.py:7) from lime.lime_tabular import LimeTabularExplainer
[9](file:///C:/Users/AAkash/Desktop/acuda/Explainable-AI-for-Early-Detection-and-Severity-Assessment-of-Alzheimer-s-Disease/lime.py:9) # %% Load and preprocess data
[10](file:///C:/Users/AAkash/Desktop/acuda/Explainable-AI-for-Early-Detection-and-Severity-Assessment-of-Alzheimer-s-Disease/lime.py:10) data_loader = DataLoader()
ModuleNotFoundError: No module named 'lime.lime_tabular'; 'lime' is not a package
Error at line 1 at lime.py file
`# %% Imports from utils import DataLoader from sklearn.ensemble import RandomForestClassifier from sklearn.metrics import f1_score, accuracy_score from interpret.blackbox import LimeTabular from interpret import show from lime.lime_tabular import LimeTabularExplainer
%% Load and preprocess data
data_loader = DataLoader() data_loader.load_dataset() data_loader.preprocess_data()
Split the data for evaluation
X_train, X_test, y_train, y_test = data_loader.get_data_split()
Oversample the train data
X_train, y_train = data_loader.oversample(X_train, y_train) print(X_train.shape) print(X_test.shape)
%% Fit blackbox model
rf = RandomForestClassifier() rf.fit(X_train, y_train) y_pred = rf.predict(X_test) print(f"F1 Score {f1_score(y_test, y_pred, average='macro')}") print(f"Accuracy {accuracy_score(y_test, y_pred)}")
%% Apply lime
Initilize Lime for Tabular data
%% Apply lime
Initialize Lime for Tabular data
lime = LimeTabular(model=rf, # Add the model argument here data=X_train.astype(float).fillna(0), # Convert the data to float type and fill NaN values with 0 random_state=1)
Get local explanations
lime_local = lime.explain_local(X_test.astype(float).fillna(0)[-20:], # Convert the data to float type and fill NaN values with 0 y_test[-20:], name='LIME')
show(lime_local)
%%
`