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