Skip to content

Commit

Permalink
Merge pull request #28 from KunjShah95/update.py
Browse files Browse the repository at this point in the history
Implement Support for Regression Models #1
  • Loading branch information
ombhojane authored Oct 3, 2024
2 parents a5e1401 + 38ca58f commit 90ef949
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions examples/regressionmodelsupport.py
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}")

0 comments on commit 90ef949

Please sign in to comment.