{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "1c01b419", "metadata": {}, "outputs": [], "source": [ "import sys\n", "sys.path.append('C://Users/11max/PycharmProjects/Mapping_ML/')\n", "import ML_mapping" ] }, { "cell_type": "markdown", "id": "888336a2", "metadata": {}, "source": [ "Arguments to initialize object:\n", "- reference_classification: a string with the reference classification name. Choices:\n", " - openIO-Canada\n", " - exiobase\n", " - USEEIO 2.0\n", " - GTAP 10\n", " - IOCC\n", " - NACE Rev.1.1\n", " - NACE Rev.2\n", " - CPA 2008\n", " - CPA 2.1\n", " - NAPCS 2017\n", " - NAPCS 2022\n", " - NAICS 2017\n", " - NAICS 2022\n", " - ISIC Rev.4\n", " - CPC 2.1\n", " - COICOP 2018\n", " - ecoinvent 3.8 technosphere\n", " - ecoinvent 3.9 technosphere\n", " - ecoinvent 3.8 elementary flows\n", " - ecoinvent 3.9 elementary flows\n", " - IMPACT World+ 2.0\n", " - USEtox 2\n", " - EF 3.0\n", " - EF 3.1\n", "- transformer_model: a string with the name of the machine learning model to use for word association. Available models: https://www.sbert.net/docs/pretrained_models.html\n", "- number_of_guessed: an integer giving the number of guesses by the model that will be displayed in the final dataframe" ] }, { "cell_type": "code", "execution_count": 2, "id": "391cde42", "metadata": {}, "outputs": [], "source": [ "self = ML_mapping.Mapping(reference_classification='exiobase',\n", " transformer_model='all-MiniLM-L6-v2',\n", " number_of_guesses=5)" ] }, { "cell_type": "markdown", "id": "1ba505c4", "metadata": {}, "source": [ "Enter a list of words to match to classifications and pass it as an argument to self.match_inputs(). Then calculate similarity scores and format/display results." ] }, { "cell_type": "code", "execution_count": 9, "id": "5a8702d1", "metadata": { "scrolled": false }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
sectorsimilarity
productorder
ADPE System Configuration1Computer and related services (72)0.229096
2Post and telecommunication services (64)0.221951
3White Spirit & SBP0.182888
4Research and development services (73)0.165665
5Other services (93)0.160532
6Education services (80)0.158538
7Air transport services (62)0.148643
8Health and social work services (85)0.140428
9Plastics, basic0.140398
10Real estate services (70)0.133257
Chocolate1Sugar0.575643
2Dairy products0.491422
3Beverages0.483462
4Gas Coke0.455178
5Raw milk0.449589
6Coke Oven Coke0.448786
7Charcoal0.43323
8Vegetables, fruit, nuts0.425549
9Wheat0.406313
10Sugar cane, sugar beet0.403211
Renting a film1Renting services of machinery and equipment wi...0.311251
2Motor vehicles, trailers and semi-trailers (34)0.259165
3Hotel and restaurant services (55)0.202232
4Real estate services (70)0.199813
5Private households with employed persons (95)0.170975
6Construction work (45)0.169991
7Printed matter and recorded media (22)0.154569
8Services auxiliary to financial intermediation...0.14115
9Cement, lime and plaster0.136944
10Electricity by solar photovoltaic0.134443
\n", "
" ], "text/plain": [ " sector \\\n", "product order \n", "ADPE System Configuration 1 Computer and related services (72) \n", " 2 Post and telecommunication services (64) \n", " 3 White Spirit & SBP \n", " 4 Research and development services (73) \n", " 5 Other services (93) \n", " 6 Education services (80) \n", " 7 Air transport services (62) \n", " 8 Health and social work services (85) \n", " 9 Plastics, basic \n", " 10 Real estate services (70) \n", "Chocolate 1 Sugar \n", " 2 Dairy products \n", " 3 Beverages \n", " 4 Gas Coke \n", " 5 Raw milk \n", " 6 Coke Oven Coke \n", " 7 Charcoal \n", " 8 Vegetables, fruit, nuts \n", " 9 Wheat \n", " 10 Sugar cane, sugar beet \n", "Renting a film 1 Renting services of machinery and equipment wi... \n", " 2 Motor vehicles, trailers and semi-trailers (34) \n", " 3 Hotel and restaurant services (55) \n", " 4 Real estate services (70) \n", " 5 Private households with employed persons (95) \n", " 6 Construction work (45) \n", " 7 Printed matter and recorded media (22) \n", " 8 Services auxiliary to financial intermediation... \n", " 9 Cement, lime and plaster \n", " 10 Electricity by solar photovoltaic \n", "\n", " similarity \n", "product order \n", "ADPE System Configuration 1 0.229096 \n", " 2 0.221951 \n", " 3 0.182888 \n", " 4 0.165665 \n", " 5 0.160532 \n", " 6 0.158538 \n", " 7 0.148643 \n", " 8 0.140428 \n", " 9 0.140398 \n", " 10 0.133257 \n", "Chocolate 1 0.575643 \n", " 2 0.491422 \n", " 3 0.483462 \n", " 4 0.455178 \n", " 5 0.449589 \n", " 6 0.448786 \n", " 7 0.43323 \n", " 8 0.425549 \n", " 9 0.406313 \n", " 10 0.403211 \n", "Renting a film 1 0.311251 \n", " 2 0.259165 \n", " 3 0.202232 \n", " 4 0.199813 \n", " 5 0.170975 \n", " 6 0.169991 \n", " 7 0.154569 \n", " 8 0.14115 \n", " 9 0.136944 \n", " 10 0.134443 " ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "self.match_inputs(['ADPE System Configuration','Chocolate','Renting a film'])\n", "self.calculate_scores()\n", "self.format_results()" ] }, { "cell_type": "code", "execution_count": null, "id": "f880349b", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.7" } }, "nbformat": 4, "nbformat_minor": 5 }