Spaces:
Sleeping
Sleeping
new comit
Browse files- main.py +0 -57
- olga.tab +0 -0
- requirements.txt +6 -6
main.py
CHANGED
@@ -1,57 +0,0 @@
|
|
1 |
-
#Example 5 Gradio Version
|
2 |
-
# Example 4 Decision Treen Analysis
|
3 |
-
# Example 2 rework on classification of flow regime type
|
4 |
-
import pandas as pd
|
5 |
-
import gradio as gr
|
6 |
-
df = pd.read_csv("olga.tab" ,sep="\t")
|
7 |
-
import matplotlib.pyplot as plt
|
8 |
-
from matplotlib.lines import Line2D
|
9 |
-
plt.figure(figsize=(16,8))
|
10 |
-
import numpy as np
|
11 |
-
from sklearn.tree import DecisionTreeClassifier
|
12 |
-
plt.rcParams['font.size'] = 16
|
13 |
-
plt.style.use("seaborn-whitegrid")
|
14 |
-
def rs(array):
|
15 |
-
return np.array(array).reshape(-1, 1)
|
16 |
-
#drop empty values
|
17 |
-
df.dropna(inplace=True)
|
18 |
-
#Redcue to stable/non stable regime 1 = Unstable, 2
|
19 |
-
df = df.dropna()
|
20 |
-
df = df[ (df["QOST [STB/d]"]>= 0) & (df["QGST [MMscf/d]"] >=0) ]
|
21 |
-
#create training values
|
22 |
-
X_train = df[["QOST [STB/d]", "QGST [MMscf/d]"]]
|
23 |
-
y_train = df["ID"]
|
24 |
-
#initialize mode
|
25 |
-
DT = DecisionTreeClassifier(max_depth=5)
|
26 |
-
#train and predict
|
27 |
-
DT.fit(X_train, y_train)
|
28 |
-
y_pred = list(DT.predict(X_train))
|
29 |
-
|
30 |
-
color_map = {1:"red", 2:"blue", 3:"green", 4:"magenta"}
|
31 |
-
y_color_original = pd.Series(y_train).map(color_map)
|
32 |
-
y_pred_color = pd.Series(y_pred).map(color_map)
|
33 |
-
#create dual pltis plot
|
34 |
-
#tcf = plt.tricontourf(df["QOST [STB/d]"], df["QGST [MMscf/d]"],y_pred , cmap="rainbow")
|
35 |
-
#plt[0].scatter(df["QOST [STB/d]"], df["QGST [MMscf/d]"], color=y_color_original, s=100, alpha=0.5)
|
36 |
-
|
37 |
-
#Create custom legend
|
38 |
-
legend_items = []
|
39 |
-
regime = ["Stratified", "Bubble", "Slug", "Annular"]
|
40 |
-
for i in range(1,5):
|
41 |
-
#Create Custom Scatter Points
|
42 |
-
scatt = Line2D([0], [0], color=color_map[i],marker="o", markersize=15, lw=0,label=regime[i-1])
|
43 |
-
legend_items.append(scatt)
|
44 |
-
#Setup Plot
|
45 |
-
|
46 |
-
def predict_model(qost, qgst):
|
47 |
-
x_pred = pd.DataFrame({"QOST [STB/d]":[qost], "QGST [MMscf/d]":[qgst]})
|
48 |
-
_pred = DT.predict(x_pred)
|
49 |
-
plt.scatter(df["QOST [STB/d]"], df["QGST [MMscf/d]"], color=y_pred_color, s=100, alpha=0.5)
|
50 |
-
plt.scatter(x_pred["QOST [STB/d]"], x_pred["QGST [MMscf/d]"], color="black",marker="X", s=200, label="Your Point")
|
51 |
-
plt.xlabel("QOST") ;plt.ylabel("QGST")
|
52 |
-
plt.legend(True,handles=legend_items)
|
53 |
-
plt.title("Original Dataset"); plt.title("Predicted Dataset")
|
54 |
-
return plt, regime[ int(_pred[0])-1 ]
|
55 |
-
interface = gr.Interface(predict_model, inputs=[gr.Number(label="QOil[bbl/day]", value=20000), gr.Number(label="QGas[mmscf/day]", value=100)],
|
56 |
-
outputs=[gr.Plot(label="Flow Map"),gr.Textbox(label="Identified Regime")])
|
57 |
-
interface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
olga.tab
DELETED
The diff for this file is too large to render.
See raw diff
|
|
requirements.txt
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
-
gradio
|
2 |
-
matplotlib
|
3 |
-
matplotlib
|
4 |
-
numpy
|
5 |
-
pandas
|
6 |
-
scikit_learn
|
|
|
1 |
+
gradio
|
2 |
+
matplotlib
|
3 |
+
matplotlib
|
4 |
+
numpy
|
5 |
+
pandas
|
6 |
+
scikit_learn
|