dperales commited on
Commit
b86c3d4
1 Parent(s): ec9b0ed

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -14
app.py CHANGED
@@ -1,10 +1,14 @@
1
  import os
2
  import pycaret
3
  from pycaret.datasets import get_data
4
- # import pycaret clustering and init setup
5
  from pycaret.clustering import *
6
- # import ClusteringExperiment and init the class
 
 
7
  from pycaret.clustering import ClusteringExperiment
 
 
8
 
9
  import matplotlib.pyplot as plt
10
  import matplotlib as mpl
@@ -20,26 +24,27 @@ def main():
20
  data = get_data('jewellery')
21
  s = setup(data, session_id = 123)
22
 
23
- exp = ClusteringExperiment()
 
24
 
25
  # init setup on exp
26
- exp.setup(data, session_id = 123)
 
27
 
28
  # train kmeans model
29
  kmeans = create_model('kmeans')
 
30
 
31
- kmeans_cluster = assign_model(kmeans)
32
- kmeans_cluster
 
 
 
33
 
34
  if st.button("Prediction"):
35
  # plot pca cluster plot
36
- plot_model(kmeans, plot = 'cluster', display_format = 'streamlit')
37
-
38
- # Convert the plot to a compatible format for Streamlit
39
- # compatible_plot = go.Figure(data=plot['data'], layout=plot['layout'])
40
-
41
- # Display the plot in Streamlit
42
- # st.plotly_chart(compatible_plot)
43
-
44
  if __name__ == '__main__':
45
  main()
 
1
  import os
2
  import pycaret
3
  from pycaret.datasets import get_data
4
+ # import pycaret clustering
5
  from pycaret.clustering import *
6
+ # import pycaret anomaly
7
+ from pycaret.anomaly import *
8
+ # import ClusteringExperiment
9
  from pycaret.clustering import ClusteringExperiment
10
+ # import AnomalyExperiment
11
+ from pycaret.anomaly import AnomalyExperiment
12
 
13
  import matplotlib.pyplot as plt
14
  import matplotlib as mpl
 
24
  data = get_data('jewellery')
25
  s = setup(data, session_id = 123)
26
 
27
+ exp_clustering = ClusteringExperiment()
28
+ exp_anomaly = AnomalyExperiment()
29
 
30
  # init setup on exp
31
+ exp_clustering.setup(data, session_id = 123)
32
+ exp_anomaly.setup(data, session_id = 123)
33
 
34
  # train kmeans model
35
  kmeans = create_model('kmeans')
36
+ iforest = create_model('iforest')
37
 
38
+ # kmeans_cluster = assign_model(kmeans)
39
+ # kmeans_cluster
40
+
41
+ iforest_anomalies = assign_model(iforest)
42
+ iforest_anomalies
43
 
44
  if st.button("Prediction"):
45
  # plot pca cluster plot
46
+ # plot_model(kmeans, plot = 'cluster', display_format = 'streamlit')
47
+ plot_model(iforest, plot = 'tsne', display_format = 'streamlit')
48
+
 
 
 
 
 
49
  if __name__ == '__main__':
50
  main()