PebinAPJ/Logistic_Regression_Brest_Cancer_
0
1import gradio as gr2import pickle3import numpy as np4 5# Load the trained model6with open("logistic_regression_model.pkl", "rb") as f:7 model = pickle.load(f)8 9def predict(features):10 """11 Predict whether the input features correspond to male or female.12 :param features: List of feature values [feature1, feature2, ...]13 :return: Prediction as a string ("Male" or "Female")14 """15 features = np.array(features).reshape(1, -1)16 prediction = model.predict(features)[0]17 return "Male" if prediction == 1 else "Female"18 19# Define the Gradio interface20inputs = [21 gr.Number(label="Feature 1"),22 gr.Number(label="Feature 2"),23 # Add more inputs as needed based on your dataset's features24]25 26output = gr.Textbox(label="Prediction")27 28description = "Predict whether the input corresponds to Male or Female using Logistic Regression"29 30demo = gr.Interface(31 fn=predict,32 inputs=inputs,33 outputs=output,34 title="Gender Prediction",35 description=description36)37 38if __name__ == "__main__":39 demo.launch()40 