{"id":23190310,"url":"https://github.com/linsanity03/flower_prediction","last_synced_at":"2026-05-07T14:49:12.654Z","repository":{"id":195538857,"uuid":"693119233","full_name":"LINSANITY03/Flower_prediction","owner":"LINSANITY03","description":"Predict the species of flower by using pre-built classifier model from tensorflow","archived":false,"fork":false,"pushed_at":"2023-09-25T11:53:32.000Z","size":6,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-12T22:54:02.260Z","etag":null,"topics":["keras","machine-learning","prediction-model","tensorflow"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LINSANITY03.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-09-18T11:44:09.000Z","updated_at":"2023-12-17T20:52:45.000Z","dependencies_parsed_at":null,"dependency_job_id":"499265b2-4c72-4d1c-877d-73857123f5ec","html_url":"https://github.com/LINSANITY03/Flower_prediction","commit_stats":null,"previous_names":["linsanity03/flower_prediction"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/LINSANITY03/Flower_prediction","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LINSANITY03%2FFlower_prediction","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LINSANITY03%2FFlower_prediction/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LINSANITY03%2FFlower_prediction/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LINSANITY03%2FFlower_prediction/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LINSANITY03","download_url":"https://codeload.github.com/LINSANITY03/Flower_prediction/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LINSANITY03%2FFlower_prediction/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279013281,"owners_count":26085250,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-12T02:00:06.719Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["keras","machine-learning","prediction-model","tensorflow"],"created_at":"2024-12-18T12:14:05.508Z","updated_at":"2025-10-12T22:54:02.697Z","avatar_url":"https://github.com/LINSANITY03.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Prediction model for classifying flower\n\nIn this project we use pandas to collect data from a source and in-built tensorflow model to train the data.\n\nTo run this project,\n\n- Create a virutal environment and activate the environment.\n  `  virtualenv venv\n\\venv\\Scripts\\activate`\n\n- Install the required dependencies.\n  `pip install -r requirements.txt\n`\n\n- Run the **main.py** file.\n  `python main.py`\n\n**1. Data Collection:**\nWe get flower training and evaluation data from google drive links.\n\n```\nimport tensorflow as tf\n...\n\ntrain_path = tf.keras.utils.get_file(\n    \"iris_training.csv\", \"https://storage.googleapis.com/download.tensorflow.org/data/iris_training.csv\")\ntest_path = tf.keras.utils.get_file(\n    \"iris_test.csv\", \"https://storage.googleapis.com/download.tensorflow.org/data/iris_test.csv\")\n\n```\n\n**2. Feature Extraction:**\nUsing the in-built feature column function of tensorflow, we get all the unique value from each column of the tf file.\n\n```\n# Feature columns describe how to use the input.\n# We use the inbuilt function in tensorflow to get all the unique value represented in the data of certain features\nmy_feature_columns = []\nfor key in train.keys():\n    my_feature_columns.append(tf.feature_column.numeric_column(key=key))\n```\n\n**3. Data Preparation:**\nWe need to make sure the data are in appropritate format for the tensorflow model. So, we convert the datas into data.Dataset object using tf.data.Dataset function\n\n```\n# convert the data into Dataset format\ndef input_fn(features, labels, training=True, batch_size=256):\n    # Convert the inputs to a Dataset.\n    dataset = tf.data.Dataset.from_tensor_slices((dict(features), labels))\n    # Shuffle and repeat if you are in training mode.\n    if training:\n        dataset = dataset.shuffle(1000).repeat()\n\n    return dataset.batch(batch_size)\n```\n\n**4. Choosing a Model:**\nOur goal is to predict the flower based on given length. So, a DNN classifier model would do the trick.\n\n```\n# Creating a model\n# Build a DNN with 2 hidden layers with 30 and 10 hidden nodes each.\nclassifier = tf.estimator.DNNClassifier(\n    feature_columns=my_feature_columns,\n    # Two hidden layers of 30 and 10 nodes respectively.\n    hidden_units=[30, 10],\n    # The model must choose between 3 classes.\n    n_classes=3)\n```\n\n**5. Training the model:**\nWe use the data we convert to data.Dataset object to the model.\n\n```\n# training the model\nclassifier.train(\n    input_fn=lambda: input_fn(train, train_y, training=True),\n    steps=5000)\n# We include a lambda to avoid creating an inner function previously\n```\n\n**6. Evaluate the model:**\nTest the unseen dataset to measure the performance of the trained model.\n\n```\n# Evaluate the model accuracy by running the same data\neval_result = classifier.evaluate(\n    input_fn=lambda: input_fn(test, test_y, training=False))\n\nprint('\\nTest set accuracy: {accuracy:0.3f}\\n'.format(**eval_result))\n'''Test set accuracy: 0.900'''\n```\n\n**7. Make prediction:**\nUsing the evaluated model predict the flower species and return flower name with probability for better readability.\n\n```\npredictions = classifier.predict(input_fn=lambda: user_input(predict))\nfor pred_dict in predictions:\n    class_id = pred_dict['class_ids'][0]\n    probability = pred_dict['probabilities'][class_id]\n\n    print('Prediction is \"{}\" ({:.1f}%)'.format(\n        SPECIES[class_id], 100 * probability))\n\n'''\nPlease type numeric values as prompted.\nSepalLength: 5.1\nSepalWidth: 5.9\nPetalLength: 1.7\nPetalWidth: 0.5\n...\nPrediction is \"Setosa\" (97.4%)\n'''\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flinsanity03%2Fflower_prediction","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flinsanity03%2Fflower_prediction","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flinsanity03%2Fflower_prediction/lists"}