File size: 430 Bytes
03ee8e8 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
import joblib
import numpy as np
# Load model and label encoder
model = joblib.load("soil.pkl")
label_encoder = joblib.load("label_encoder.pkl")
def predict(inputs):
"""
Inputs: List of 7 features [N, P, K, temperature, humidity, ph, rainfall]
"""
input_array = np.array(inputs).reshape(1, -1)
prediction = model.predict(input_array)
crop = label_encoder.inverse_transform(prediction)
return crop[0]
|