loubnabnl's picture
loubnabnl HF staff
Update utils/examples.json
e3fb687
[
{
"name": "Hello World!",
"value": "def print_hello_world():\n \"\"\"Print 'Hello World!'.\"\"\"",
"length": 8
},
{
"name": "Scikit-Learn",
"value": "import numpy as np\nfrom sklearn.ensemble import RandomForestClassifier\n\n# create training data\nX = np.random.randn(100, 100)\ny = np.random.randint(0, 1, 100)\n\n# setup train test split",
"length": 52
},
{
"name": "Transformers",
"value": "from transformers import AutoTokenizer, AutoModelForSequenceClassification\n\n# build a BERT classifier",
"length": 48
},
{
"name": "Count words",
"value": "def count_words(filename):\n \"\"\"Count the number of occurrences of each word in the file\"\"\"",
"length": 48
},
{
"name": "Is e in L",
"value": "def is_in_list(L, e):\n \"\"\"Find if list L contains the element e.\"\"\"",
"length": 32
},
{
"name": "unittest",
"value": "def is_even(value):\n \"\"\"Returns True if value is an even number.\"\"\"\n return value % 2 == 0\n\n# setup unit tests for is_even\nimport unittest",
"length": 52
},
{
"name": "Pizza Problem",
"value": "def exercise():\n \"\"\"Marie ordered one chicken meal that costs 12 dollars, and some boxes of pizza. Marie paid a total of 44 dollars. How many boxes of pizza did Marie order if each box costs 8 dollars?\"\"\"",
"length": 52
},
{
"name": "Pandas",
"value": "# load dataframe from csv\ndf = pd.read_csv(filename)\n\n# columns: \"age_group\", \"income\"\n# calculate average income per age group",
"length": 16
}
]