import pandas as pd import numpy as np import pickle #from scipy import stats from sklearn.preprocessing import MinMaxScaler, StandardScaler, PolynomialFeatures from sklearn.linear_model import Ridge, ElasticNet, LinearRegression, Lasso from sklearn.model_selection import train_test_split #import sweetviz as sv #import dtale import gradio as gr # # Load the dataset # df = pd.read_csv('ebw_data.csv') # X = df.drop(['Width', 'Depth'], axis=1) # y = df[['Width', 'Depth']] # # Разделим данные на трэйн и тест # X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=0) # # Создайте экземпляр модели линейной регрессии. # model = LinearRegression() # # Фитим # model.fit(X_train, y_train) # # Предиктим # y_pred = model.predict(X_test) # # Оценка производительности модели # score = model.score(X_test, y_test) # #print('Accuracy:', score) filename = 'finalized_model.sav' model = pickle.load(open(filename, 'rb')) #result = loaded_model.score(X_test, Y_test) # print(result) def greet(IW, IF, VW, FP): X_new = pd.DataFrame({'IW': [IW], 'IF': [IF], 'VW': [VW], 'FP': [FP]}) y_predd = model.predict(X_new) arr_reshaped = np.reshape(y_predd, (2, 1)) arr1, arr2 = np.split(arr_reshaped, 2) value1 = arr1[0] value2 = arr2[0] return value1, value2 inputs = [gr.Slider(43, 49), gr.Slider(131, 150), gr.Slider(4.5, 10), gr.Slider(50, 125)] outputs = [gr.Number(label="Width"), gr.Number(label="Depth")] demo = gr.Interface( fn=greet, inputs=inputs, outputs=outputs, title="Predict Depth and Width" ) demo.launch()