-
-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from KunjShah95/update.py
Implement Support for Regression Models #1
- Loading branch information
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import pandas as pd | ||
from explainableai import XAIWrapper | ||
from sklearn.ensemble import RandomForestRegressor | ||
from sklearn.linear_model import LinearRegression | ||
from xgboost import XGBRegressor | ||
from sklearn.neural_network import MLPRegressor | ||
|
||
# Load your dataset | ||
df = pd.read_csv('your_dataset.csv') | ||
X = df.drop(columns=['target_column']) | ||
y = df['target_column'] | ||
|
||
# Perform EDA | ||
XAIWrapper.perform_eda(df) | ||
|
||
# Create models | ||
models = { | ||
'Random Forest': RandomForestRegressor(n_estimators=100, random_state=42), | ||
'Linear Regression': LinearRegression(), | ||
'XGBoost': XGBRegressor(n_estimators=100, random_state=42), | ||
'Neural Network': MLPRegressor(hidden_layer_sizes=(100, 50), max_iter=1000, random_state=42) | ||
} | ||
|
||
# Create XAIWrapper instance and fit models | ||
xai = XAIWrapper() | ||
xai.fit(models, X, y) | ||
results = xai.analyze() | ||
|
||
# Print LLM explanation of results | ||
print(results['llm_explanation']) | ||
|
||
# Generate a comprehensive report | ||
xai.generate_report('xai_report.pdf') | ||
|
||
# Make a prediction with explanation | ||
new_data = {...} # Dictionary of feature values | ||
prediction, probabilities, explanation = xai.explain_prediction(new_data) | ||
print(f"Prediction: {prediction}") | ||
print(f"Probabilities: {probabilities}") | ||
print(f"Explanation: {explanation}") |