Briankabiru commited on
Commit
7d2a6fa
·
verified ·
1 Parent(s): 7261a0f

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +57 -4
README.md CHANGED
@@ -56,9 +56,62 @@ The model was evaluated using the following metrics:
56
 
57
  ## How to Use
58
 
59
- ### Installation
60
 
61
- To install the necessary packages, run:
 
 
 
 
 
 
 
 
 
62
 
63
- ```bash
64
- pip install -r Requirements.txt
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
 
57
  ## How to Use
58
 
59
+ ### Input Format
60
 
61
+ The model expects input data in JSON format with the following fields:
62
+ - "Crop Name": String
63
+ - "Target Yield": Numeric
64
+ - "Field Size": Numeric
65
+ - "pH (water)": Numeric
66
+ - "Organic Carbon": Numeric
67
+ - "Total Nitrogen": Numeric
68
+ - "Phosphorus (M3)": Numeric
69
+ - "Potassium (exch.)": Numeric
70
+ - "Soil moisture": Numeric
71
 
72
+ ### Preprocessing Steps
73
+
74
+ 1. Load your input data.
75
+ 2. Ensure all required fields are present and in the expected format.
76
+ 3. Handle any missing values if necessary.
77
+ 4. Scale numerical features based on the training data.
78
+ 5. One-hot encode categorical features (if applicable).
79
+
80
+ ### Inference Procedure
81
+
82
+ #### Example Code:
83
+
84
+ ```python
85
+ from sklearn.externals import joblib
86
+ import pandas as pd
87
+
88
+ # Load the trained model
89
+ model = joblib.load('random_forest_model.joblib')
90
+
91
+ # Example input data
92
+ new_data = {
93
+ 'Crop Name': 'apple',
94
+ 'Target Yield': 1200.0,
95
+ 'Field Size': 1.0,
96
+ 'pH (water)': 5.76,
97
+ 'Organic Carbon': 12.9,
98
+ 'Total Nitrogen': 1.1,
99
+ 'Phosphorus (M3)': 1.2,
100
+ 'Potassium (exch.)': 1.7,
101
+ 'Soil moisture': 11.4
102
+ }
103
+
104
+ # Preprocess the input data
105
+ input_df = pd.DataFrame([new_data])
106
+
107
+ # Ensure the same columns as in training
108
+ input_df = pd.get_dummies(input_df, columns=['Crop Name'])
109
+ for col in X.columns:
110
+ if col not in input_df.columns:
111
+ input_df[col] = 0
112
+
113
+ # Make predictions
114
+ predictions = model.predict(input_df)
115
+
116
+ print("Predicted nutrient needs:")
117
+ print(predictions)