SoooSlooow commited on
Commit
09d933c
1 Parent(s): 3310680

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -14
app.py CHANGED
@@ -10,28 +10,20 @@ import pandas as pd
10
  OUTPUT_DATA_PATH = "data/processed/app_dataset.csv"
11
  PREDICTIONS_PATH = "models/predictions/app_predictions.csv"
12
  UNIQUE_VALUES_PATH = "models/other/unique_column_values.pkl"
 
13
 
14
 
15
  def predict(*args: tuple) -> Any:
16
  app_df = pd.DataFrame(data=[args], columns=columns, index=[0])
17
  app_df.to_csv(OUTPUT_DATA_PATH, index=False)
18
- subprocess.run(
19
- [
20
- "python",
21
- "-m",
22
- "src.models.make_predictions",
23
- "data/processed/app_dataset.csv",
24
- "models/final_model.pkl",
25
- "models/predictions/app_predictions.csv",
26
- ],
27
- shell=True,
28
- )
29
- predictions = np.genfromtxt(PREDICTIONS_PATH, delimiter=",", skip_header=1)
30
- if predictions[2] == 1:
31
  message = "Client is considered bad. Issuance of credit is not recommended."
32
  else:
33
  message = "Client is considered good. Issuance of credit is allowed."
34
- return round(predictions[0], 3), message
35
 
36
 
37
  columns = (
 
10
  OUTPUT_DATA_PATH = "data/processed/app_dataset.csv"
11
  PREDICTIONS_PATH = "models/predictions/app_predictions.csv"
12
  UNIQUE_VALUES_PATH = "models/other/unique_column_values.pkl"
13
+ MODEL_PATH = "models/final_model.pkl"
14
 
15
 
16
  def predict(*args: tuple) -> Any:
17
  app_df = pd.DataFrame(data=[args], columns=columns, index=[0])
18
  app_df.to_csv(OUTPUT_DATA_PATH, index=False)
19
+ model = joblib.load(MODEL_PATH)
20
+ predictions = model.predict_proba(app_df)
21
+ print(predictions)
22
+ if predictions[0][0] <= 0.99:
 
 
 
 
 
 
 
 
 
23
  message = "Client is considered bad. Issuance of credit is not recommended."
24
  else:
25
  message = "Client is considered good. Issuance of credit is allowed."
26
+ return round(predictions[0][0], 3), message
27
 
28
 
29
  columns = (