mardrake commited on
Commit
d1a1266
·
1 Parent(s): 7c92df4

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +49 -0
app.py ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pandas as pd
2
+ from scipy import stats
3
+ from sklearn.preprocessing import MinMaxScaler, StandardScaler, PolynomialFeatures
4
+ from sklearn.linear_model import Ridge, ElasticNet, LinearRegression, Lasso
5
+ from sklearn.model_selection import train_test_split
6
+ import sweetviz as sv
7
+ import dtale
8
+ import gradio as gr
9
+
10
+ # Load the dataset
11
+ df = pd.read_csv('ebw_data.csv')
12
+
13
+ X = df.drop(['Width', 'Depth'], axis=1)
14
+ y = df[['Width', 'Depth']]
15
+
16
+ # Разделим данные на трэйн и тест
17
+ X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=0)
18
+
19
+ # Создайте экземпляр модели линейной регрессии.
20
+ model = LinearRegression()
21
+
22
+ # Фитим
23
+ model.fit(X_train, y_train)
24
+
25
+ # Предиктим
26
+ y_pred = model.predict(X_test)
27
+
28
+ # Оценка производительности модели
29
+ score = model.score(X_test, y_test)
30
+ #print('Accuracy:', score)
31
+ def greet(IW, IF, VW, FP):
32
+ X_new = pd.DataFrame({'IW': [IW], 'IF': [IF], 'VW': [VW], 'FP': [FP]})
33
+ y_predd = model.predict(X_new)
34
+ arr_reshaped = np.reshape(y_predd, (2, 1))
35
+ arr1, arr2 = np.split(arr_reshaped, 2)
36
+ value1 = arr1[0]
37
+ value2 = arr2[0]
38
+ return value1, value2
39
+
40
+ inputs = [gr.Slider(43, 49), gr.Slider(131, 150), gr.Slider(4.5, 10), gr.Slider(50, 125)]
41
+ outputs = [gr.Number(label="Width"), gr.Number(label="Depth")]
42
+
43
+ demo = gr.Interface(
44
+ fn=greet,
45
+ inputs=inputs,
46
+ outputs=outputs,
47
+ title="Predict Depth and Width"
48
+ )
49
+ demo.launch()