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
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.