Shafanda Nabil Sembodo commited on
Commit
7f5ad9a
·
1 Parent(s): f084249
Files changed (2) hide show
  1. app.py +20 -16
  2. logs.log +54 -0
app.py CHANGED
@@ -5,8 +5,8 @@ from pycaret.classification import *
5
 
6
  os.environ['MLFLOW_TRACKING_USERNAME'] = 'fandanabil1379'
7
  os.environ['MLFLOW_TRACKING_PASSWORD'] = 'dadc32f6246f307c2fe4928f3074068f628b79ba'
8
- os.environ["HF_HOME"] = '~/.cache/huggingface'
9
 
 
10
  def convert_df(df):
11
  return df.to_csv(index=False).encode('utf-8')
12
 
@@ -23,18 +23,22 @@ def load_model():
23
  loaded_model = mlflow.sklearn.load_model(f"models:/{model_name}/{stage}")
24
  return loaded_model
25
 
26
- # load data
27
- uploaded_file = st.file_uploader("Choose a file", type={"csv"})
28
- if uploaded_file is not None:
29
- # do prediction
30
- df = pd.read_csv(uploaded_file)
31
- model = load_model()
32
- prediction = predict_model(model, df).drop(columns='Unnamed: 0')
33
-
34
- # show the result
35
- st.write(prediction)
36
-
37
- # download the result
38
- csv = convert_df(prediction)
39
- if st.download_button('Download Prediction', csv, 'prediction.csv'):
40
- st.write('Thanks for downloading!')
 
 
 
 
 
5
 
6
  os.environ['MLFLOW_TRACKING_USERNAME'] = 'fandanabil1379'
7
  os.environ['MLFLOW_TRACKING_PASSWORD'] = 'dadc32f6246f307c2fe4928f3074068f628b79ba'
 
8
 
9
+ @st.cache_data
10
  def convert_df(df):
11
  return df.to_csv(index=False).encode('utf-8')
12
 
 
23
  loaded_model = mlflow.sklearn.load_model(f"models:/{model_name}/{stage}")
24
  return loaded_model
25
 
26
+ @st.cache_data(experimental_allow_widgets=True)
27
+ def prediction():
28
+ # load data
29
+ uploaded_file = st.file_uploader("Choose a file", type={"csv"})
30
+ if uploaded_file is not None:
31
+ # do prediction
32
+ df = pd.read_csv(uploaded_file)
33
+ model = load_model()
34
+ prediction = predict_model(model, df).drop(columns='Unnamed: 0')
35
+
36
+ # show the result
37
+ st.write(prediction)
38
+
39
+ # download the result
40
+ csv = convert_df(prediction)
41
+ if st.download_button('Download Prediction', csv, 'prediction.csv'):
42
+ st.write('Thanks for downloading!')
43
+
44
+ prediction()
logs.log CHANGED
@@ -157,3 +157,57 @@ Feature names unseen at fit time:
157
  2023-08-03 10:59:29,379:INFO:Preloading libraries
158
  2023-08-03 10:59:29,379:INFO:Set up data.
159
  2023-08-03 10:59:29,386:INFO:Set up index.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
157
  2023-08-03 10:59:29,379:INFO:Preloading libraries
158
  2023-08-03 10:59:29,379:INFO:Set up data.
159
  2023-08-03 10:59:29,386:INFO:Set up index.
160
+ 2023-08-04 07:20:45,982:WARNING:
161
+ 'cuml' is a soft dependency and not included in the pycaret installation. Please run: `pip install cuml` to install.
162
+ 2023-08-04 07:20:45,982:WARNING:
163
+ 'cuml' is a soft dependency and not included in the pycaret installation. Please run: `pip install cuml` to install.
164
+ 2023-08-04 07:20:45,982:WARNING:
165
+ 'cuml' is a soft dependency and not included in the pycaret installation. Please run: `pip install cuml` to install.
166
+ 2023-08-04 07:20:45,982:WARNING:
167
+ 'cuml' is a soft dependency and not included in the pycaret installation. Please run: `pip install cuml` to install.
168
+ 2023-08-04 07:20:53,862:INFO:Initializing predict_model()
169
+ 2023-08-04 07:20:53,862:INFO:predict_model(self=<pycaret.classification.oop.ClassificationExperiment object at 0x28219fd00>, estimator=Pipeline(memory=FastMemory(location=/var/folders/vh/81ldn_315vdf1b2_lnntkb080000gn/T/joblib),
170
+ steps=[('combine',
171
+ TransformerWrapper(transformer=TransformerWrapper(include=['ed'],
172
+ transformer=Combine()))),
173
+ ('remove outlier',
174
+ TransformerWrapper(transformer=TransformerWrapper(transformer=RemoveOutliers(random_state=42)))),
175
+ ('normalize',
176
+ TransformerWrapper(transformer=TransformerWrapper(exclude=['ed',
177
+ 'age'],
178
+ transformer=RobustScaler()))),
179
+ ('actual_estimator',
180
+ LogisticRegression(C=8.956999999999999,
181
+ class_weight='balanced', max_iter=1000,
182
+ random_state=42))]), probability_threshold=None, encoded_labels=False, raw_score=False, round=4, verbose=True, ml_usecase=None, preprocess=True, encode_labels=<function _SupervisedExperiment.predict_model.<locals>.encode_labels at 0x282183310>)
183
+ 2023-08-04 07:20:53,862:INFO:Checking exceptions
184
+ 2023-08-04 07:20:53,862:INFO:Preloading libraries
185
+ 2023-08-04 07:20:53,864:INFO:Set up data.
186
+ 2023-08-04 07:20:53,873:INFO:Set up index.
187
+ 2023-08-04 07:22:16,503:WARNING:
188
+ 'cuml' is a soft dependency and not included in the pycaret installation. Please run: `pip install cuml` to install.
189
+ 2023-08-04 07:22:16,503:WARNING:
190
+ 'cuml' is a soft dependency and not included in the pycaret installation. Please run: `pip install cuml` to install.
191
+ 2023-08-04 07:22:16,503:WARNING:
192
+ 'cuml' is a soft dependency and not included in the pycaret installation. Please run: `pip install cuml` to install.
193
+ 2023-08-04 07:22:16,503:WARNING:
194
+ 'cuml' is a soft dependency and not included in the pycaret installation. Please run: `pip install cuml` to install.
195
+ 2023-08-04 07:23:22,156:INFO:Initializing predict_model()
196
+ 2023-08-04 07:23:22,157:INFO:predict_model(self=<pycaret.classification.oop.ClassificationExperiment object at 0x1715802e0>, estimator=Pipeline(memory=FastMemory(location=/var/folders/vh/81ldn_315vdf1b2_lnntkb080000gn/T/joblib),
197
+ steps=[('combine',
198
+ TransformerWrapper(transformer=TransformerWrapper(include=['ed'],
199
+ transformer=Combine()))),
200
+ ('remove outlier',
201
+ TransformerWrapper(transformer=TransformerWrapper(transformer=RemoveOutliers(random_state=42)))),
202
+ ('normalize',
203
+ TransformerWrapper(transformer=TransformerWrapper(exclude=['ed',
204
+ 'age'],
205
+ transformer=RobustScaler()))),
206
+ ('actual_estimator',
207
+ LogisticRegression(C=8.956999999999999,
208
+ class_weight='balanced', max_iter=1000,
209
+ random_state=42))]), probability_threshold=None, encoded_labels=False, raw_score=False, round=4, verbose=True, ml_usecase=None, preprocess=True, encode_labels=<function _SupervisedExperiment.predict_model.<locals>.encode_labels at 0x171536dc0>)
210
+ 2023-08-04 07:23:22,157:INFO:Checking exceptions
211
+ 2023-08-04 07:23:22,157:INFO:Preloading libraries
212
+ 2023-08-04 07:23:22,159:INFO:Set up data.
213
+ 2023-08-04 07:23:22,167:INFO:Set up index.