JohanBeytell commited on
Commit
9083a77
·
verified ·
1 Parent(s): 38cdab9

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +166 -3
README.md CHANGED
@@ -1,3 +1,166 @@
1
- ---
2
- license: mit
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ language:
4
+ - en
5
+ metrics:
6
+ - precision
7
+ - recall
8
+ - f1
9
+ - accuracy
10
+ pipeline_tag: tabular-classification
11
+ tags:
12
+ - classification
13
+ - mushrooms
14
+ ---
15
+
16
+ # Model Card for Infinitode/MCM-OPEN-ARC
17
+
18
+ Repository: https://github.com/Infinitode/OPEN-ARC/
19
+
20
+ ## Model Description
21
+
22
+ OPEN-ARC-MC is a simple RandomForestClassifier model developed as part of Infinitode's OPEN-ARC initiative. It was designed to determine whether a mushroom is edible or inedible, based on its appearance, habitat, and several other factors.
23
+
24
+ **Architecture**:
25
+
26
+ - **RandomForestClassifier**: `random_state=42`, `class_weight="balanced"`.
27
+ - **Framework**: SKLearn
28
+ - **Training Setup**: Trained using the default params.
29
+
30
+ ## Uses
31
+
32
+ - Identifying potentially poisonous mushrooms to avoid their consumption.
33
+ - Advancing knowledge and research in mushroom edibility and toxicology.
34
+
35
+ ## Limitations
36
+
37
+ - May provide inaccurate assessments regarding mushroom edibility; caution is advised when considering these outputs. Always consult expert human guidance.
38
+
39
+ ### Disclaimer
40
+
41
+ This model is intended solely for educational purposes and must not be utilized for real-life mushroom classification or any decision-making processes regarding mushroom consumption. Although the model demonstrates strong performance on the provided dataset, it has not undergone comprehensive validation for real-world applications and may fail to reliably identify poisonous mushrooms under all circumstances. Always seek advice from an expert or rely on trusted resources when identifying mushrooms.
42
+
43
+ ## Training Data
44
+
45
+ - Dataset: Mushroom Classification dataset from Kaggle.
46
+ - Source URL: https://www.kaggle.com/datasets/uciml/mushroom-classification
47
+ - Content: Mushroom appearance, and other factors, along with the edibility of the mushroom.
48
+ - Size: 8124 entries of mushroom features and target values.
49
+ - Preprocessing: Mapped all string values to numeric values.
50
+
51
+ ## Training Procedure
52
+
53
+ - Metrics: accuracy (CV), precision, recall, F1
54
+ - Train/Testing Split: 80% train, 20% testing.
55
+
56
+ ## Evaluation Results
57
+
58
+ | Metric | Value |
59
+ | ------ | ----- |
60
+ | Testing Accuracy (CV 5-fold) | 91.0% |
61
+ | Testing Weighted Average Precision | 100% |
62
+ | Testing Weighted Average Recall | 100% |
63
+ | Testing Weighted Average F1 | 100% |
64
+
65
+ ## How to Use
66
+
67
+ ```python
68
+ feature_options = {
69
+ 'cap-shape': {'b': 'bell', 'c': 'conical', 'x': 'convex', 'f': 'flat', 'k': 'knobbed', 's': 'sunken'},
70
+ 'cap-surface': {'f': 'fibrous', 'g': 'grooves', 'y': 'scaly', 's': 'smooth'},
71
+ 'cap-color': {'n': 'brown', 'b': 'buff', 'c': 'cinnamon', 'g': 'gray', 'r': 'green', 'p': 'pink', 'u': 'purple', 'e': 'red', 'w': 'white', 'y': 'yellow'},
72
+ 'bruises': {'t': 'bruises', 'f': 'no'},
73
+ 'odor': {'a': 'almond', 'l': 'anise', 'c': 'creosote', 'y': 'fishy', 'f': 'foul', 'm': 'musty', 'n': 'none', 'p': 'pungent', 's': 'spicy'},
74
+ 'gill-attachment': {'a': 'attached', 'd': 'descending', 'f': 'free', 'n': 'notched'},
75
+ 'gill-spacing': {'c': 'close', 'w': 'crowded', 'd': 'distant'},
76
+ 'gill-size': {'b': 'broad', 'n': 'narrow'},
77
+ 'gill-color': {'k': 'black', 'n': 'brown', 'b': 'buff', 'h': 'chocolate', 'g': 'gray', 'r': 'green', 'o': 'orange', 'p': 'pink', 'u': 'purple', 'e': 'red', 'w': 'white', 'y': 'yellow'},
78
+ 'stalk-shape': {'e': 'enlarging', 't': 'tapering'},
79
+ 'stalk-root': {'b': 'bulbous', 'c': 'club', 'u': 'cup', 'e': 'equal', 'z': 'rhizomorphs', 'r': 'rooted', '?': 'missing'},
80
+ 'stalk-surface-above-ring': {'f': 'fibrous', 'y': 'scaly', 'k': 'silky', 's': 'smooth'},
81
+ 'stalk-surface-below-ring': {'f': 'fibrous', 'y': 'scaly', 'k': 'silky', 's': 'smooth'},
82
+ 'stalk-color-above-ring': {'n': 'brown', 'b': 'buff', 'c': 'cinnamon', 'g': 'gray', 'o': 'orange', 'p': 'pink', 'e': 'red', 'w': 'white', 'y': 'yellow'},
83
+ 'stalk-color-below-ring': {'n': 'brown', 'b': 'buff', 'c': 'cinnamon', 'g': 'gray', 'o': 'orange', 'p': 'pink', 'e': 'red', 'w': 'white', 'y': 'yellow'},
84
+ 'veil-type': {'p': 'partial', 'u': 'universal'},
85
+ 'veil-color': {'n': 'brown', 'o': 'orange', 'w': 'white', 'y': 'yellow'},
86
+ 'ring-number': {'n': 'none', 'o': 'one', 't': 'two'},
87
+ 'ring-type': {'c': 'cobwebby', 'e': 'evanescent', 'f': 'flaring', 'l': 'large', 'n': 'none', 'p': 'pendant', 's': 'sheathing', 'z': 'zone'},
88
+ 'spore-print-color': {'k': 'black', 'n': 'brown', 'b': 'buff', 'h': 'chocolate', 'r': 'green', 'o': 'orange', 'u': 'purple', 'w': 'white', 'y': 'yellow'},
89
+ 'population': {'a': 'abundant', 'c': 'clustered', 'n': 'numerous', 's': 'scattered', 'v': 'several', 'y': 'solitary'},
90
+ 'habitat': {'g': 'grasses', 'l': 'leaves', 'm': 'meadows', 'p': 'paths', 'u': 'urban', 'w': 'waste', 'd': 'woods'}
91
+ }
92
+
93
+ def get_user_input():
94
+ """
95
+ Collects user input for each mushroom feature.
96
+
97
+ Returns:
98
+ dict: A dictionary containing the user's input for each feature.
99
+ """
100
+ user_input = {}
101
+ print("Please provide the following mushroom characteristics:")
102
+ for feature, options in feature_options.items():
103
+ print(f"\n{feature.replace('-', ' ').capitalize()}:")
104
+ for key, value in options.items():
105
+ print(f" {key}: {value}")
106
+ while True:
107
+ choice = input(f"Enter the corresponding letter for {feature}: ").strip().lower()
108
+ if choice in options:
109
+ user_input[feature] = choice
110
+ break
111
+ else:
112
+ print("Invalid input. Please enter one of the listed letters.")
113
+ return user_input
114
+
115
+ user_input = get_user_input()
116
+
117
+ def predict_mushroom(features):
118
+ """
119
+ Predict whether a mushroom is edible or poisonous based on its features.
120
+
121
+ Parameters:
122
+ features (dict): A dictionary of mushroom features with feature names as keys and corresponding categorical values.
123
+
124
+ Returns:
125
+ str: 'Edible' or 'Poisonous'
126
+ """
127
+ # Load the trained model and mappings
128
+ model = joblib.load('mushroom_classifier.pkl')
129
+ mappings = joblib.load('mappings.pkl')
130
+
131
+ # Initialize a dictionary to hold the numerical features
132
+ numerical_features = {}
133
+
134
+ # Map each feature to its numerical value
135
+ for feature, value in features.items():
136
+ if feature in mappings:
137
+ if value in mappings[feature]:
138
+ numerical_features[feature] = mappings[feature][value]
139
+ else:
140
+ raise ValueError(f"Invalid value '{value}' for feature '{feature}'.")
141
+ else:
142
+ raise ValueError(f"Feature '{feature}' is not recognized.")
143
+
144
+ # Convert the numerical features into a DataFrame
145
+ input_df = pd.DataFrame([numerical_features])
146
+
147
+ # Predict using the trained model
148
+ prediction = model.predict(input_df)
149
+
150
+ # Interpret the prediction
151
+ if prediction[0] == 0:
152
+ return 'Edible'
153
+ else:
154
+ return 'Poisonous'
155
+
156
+ # Predict edibility
157
+ try:
158
+ result = predict_mushroom(user_input)
159
+ print(f"\nThe mushroom is likely: {result}")
160
+ except ValueError as e:
161
+ print(f"Error: {e}")
162
+ ```
163
+
164
+ ## Contact
165
+
166
+ For questions or issues, open a GitHub issue or reach out at https://infinitode.netlify.app/forms/contact.