Downloads · 30 days
0
AlexFedyuk/Demo_lin
Demo_lin is a machine learning model from AlexFedyuk. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
import numpy as np from sklearn.linearmodel import LinearRegression import gradio as gr
Downloads · 30 days
0
Access
Public
Updated Oct 13, 2023
Repo size
—
Likes
0
Public
Click a slice to open those files.
Other3 KB · 67%
From the Hugging Face model README
import numpy as np from sklearn.linear_model import LinearRegression import gradio as gr
X_train = np.array([[1, 1], [2, 2], [3, 3]]) # Пример признаков y_train = np.array([1, 2, 3]) # Пример целевых переменных (ответов)
model = LinearRegression() model.fit(X_train, y_train)
def predict(input_data): # Разбиваем входную строку на пары чисел, используя точку с запятой и пробел как разделители input_pairs = input_data.split('; ')
# Преобразуем пары чисел в список списков
input_list = [list(map(float, pair.split(', '))) for pair in input_pairs]
# Преобразуем список в массив NumPy
input_array = np.array(input_list)
# Выполняем предсказание
predictions = model.predict(input_array)
return predictions
input_component = gr.components.Textbox(lines=1, placeholder="Введите признаки в формате '1, 2; 2, 3; 3, 4'")
interface = gr.Interface(fn=predict, inputs=input_component, outputs="text", live=True)
interface.launch()