loubnabnl's picture
loubnabnl HF staff
update examples
6be3129
raw
history blame
1.55 kB
[
{
"name": "Hello World!",
"value": "def print_hello_world():\n \"\"\"Print 'Hello World!'.\"\"\"",
"length": 8
},
{
"name": "Is_in_list",
"value": "def is_in_list(L, e):\n \"\"\"Find if list L contains the element e.\"\"\"",
"length": 32
},
{
"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": 96
},
{
"name": "Filesize",
"value": "def get_file_size(filepath):",
"length": 64
},
{
"name": "Python to Numpy",
"value": "# native Python:\ndef mean(a):\n return sum(a)/len(a)\n\n# with numpy:\nimport numpy as np\n\ndef mean(a):",
"length": 16
},
{
"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": 64
},
{
"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
},
{
"name": "Transformers",
"value": "from transformers import AutoTokenizer, AutoModelForSequenceClassification\n\n# build a BERT classifier",
"length": 48
}
]