|
13 | 13 | from imports import * |
14 | 14 | from dashboard import * |
15 | 15 | from calculate_shap import * |
16 | | -""" |
17 | | -This class calculates feature importance |
18 | | -
|
19 | | -Input: |
20 | | -
|
21 | | -
|
22 | | -""" |
23 | | - |
24 | 16 |
|
25 | 17 | class explain(): |
26 | 18 | def __init__(self): |
27 | 19 | super(explain, self).__init__() |
28 | 20 | self.param= {} |
| 21 | + print("Get you API key here https://www.explainx.ai/.") |
| 22 | + self.key="" |
| 23 | + self.secret="" |
29 | 24 |
|
30 | 25 | # is classification function? |
31 | 26 |
|
@@ -56,6 +51,7 @@ def ai(self, df, y, model, model_name="xgboost", mode=None): |
56 | 51 | prediction_col=[] |
57 | 52 |
|
58 | 53 | if model_name == "xgboost": |
| 54 | + import xgboost |
59 | 55 | prediction_col = model.predict(xgboost.DMatrix(df)) |
60 | 56 |
|
61 | 57 | elif model_name == "catboost": |
@@ -115,7 +111,11 @@ def ai(self, df, y, model, model_name="xgboost", mode=None): |
115 | 111 |
|
116 | 112 | self.param["is_classification"]= is_classification |
117 | 113 |
|
118 | | - d= dashboard() |
| 114 | + d= dashboard(self.key, self.secret) |
| 115 | + allowed= d.increate_counter(model_name) |
| 116 | + if allowed==False: |
| 117 | + print("API key and secret are not correct. Please signup to access the API key here https://www.explainx.ai/.") |
| 118 | + return False |
119 | 119 | d.find(self.df_final, y_variable, y_variable_predict, mode, self.param) |
120 | 120 |
|
121 | 121 | return True |
@@ -143,6 +143,10 @@ def dataset_heloc(self): |
143 | 143 | X= dataset.drop("RiskPerformance", axis=1) |
144 | 144 | return X,y |
145 | 145 |
|
| 146 | + def init(self, key="", secret=""): |
| 147 | + self.key=key |
| 148 | + self.secret= secret |
| 149 | + |
146 | 150 |
|
147 | 151 |
|
148 | 152 |
|
|
0 commit comments