Skip to content
This repository was archived by the owner on Apr 24, 2025. It is now read-only.

Commit a9d3b2b

Browse files
committed
data with front-end
1 parent b9918f1 commit a9d3b2b

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed
130 KB
Binary file not shown.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import streamlit as st
2+
import numpy as np
3+
import pandas as pd
4+
from sklearn.cluster import KMeans
5+
from sklearn.model_selection import train_test_split
6+
from sklearn.linear_model import LogisticRegression
7+
from sklearn.metrics import classification_report
8+
data = pd.read_excel("data.xlsx")
9+
y = data['label']
10+
X = data.drop(["label"], axis=1)
11+
X_train, X_test, y_train, y_test = train_test_split(
12+
X, y, test_size=0.3, random_state=0)
13+
lr = LogisticRegression()
14+
lr.fit(X_train, y_train)
15+
16+
17+
def predict_crop(input_data):
18+
crop_label = lr.predict(input_data)
19+
return crop_label[0]
20+
21+
22+
def main():
23+
st.title("Agriculture Optimisation App")
24+
st.write("Enter the parameter values to predict the crop label:")
25+
26+
n = st.number_input("N", value=0.0)
27+
p = st.number_input("P", value=0.0)
28+
k = st.number_input("K", value=0.0)
29+
temperature = st.number_input("Temperature", value=0.0)
30+
humidity = st.number_input("Humidity", value=0.0)
31+
ph = st.number_input("pH", value=0.0)
32+
rainfall = st.number_input("Rainfall", value=0.0)
33+
34+
input_data = np.array([[n, p, k, temperature, humidity, ph, rainfall]])
35+
36+
crop_label = predict_crop(input_data)
37+
38+
st.subheader("Predicted Crop Label:")
39+
st.write(crop_label)
40+
41+
42+
if __name__ == '__main__':
43+
main()

0 commit comments

Comments
 (0)