CoolFace
Datasetpublic

23ws-LLMcoder/LLMcoder-GitHub-Python-Mix-Direct

Dataset Card for LLMcoder-GitHub-Python-Mix-Direct Python target autocomplete suggestions in the format of conversations for OpenAI's fine-tuning. Dataset Details Dataset Description Curated by: [More Information Needed] Funded by [optional]: [More Information Needed] Shared by [optional]: [More Information Needed] Language(s) (NLP): [More Information Needed] License: [More Information Needed] Dataset Sources [optional] The data… See the full description on the dataset page: https://huggingface.co/datasets/23ws-LLMcoder/LLMcoder-GitHub-Python-Mix-Direct.

sourceHugging Faceupdated 3y agoView on Hugging Face
0likes216downloads
input.txt224 linesDownload Raw Back to pair_80
1 2    arr = np.repeat([0.0, 1.0], n_points)  # binary3    assert_almost_equal(matthews_corrcoef(arr, arr), 1.0)4    arr = np.repeat([0.0, 1.0, 2.0], n_points)  # multiclass5    assert_almost_equal(matthews_corrcoef(arr, arr), 1.0)6 7    y_true, y_pred = random_ys(n_points)8    assert_almost_equal(matthews_corrcoef(y_true, y_true), 1.0)9    assert_almost_equal(matthews_corrcoef(y_true, y_pred), mcc_safe(y_true, y_pred))10 11 12def test_precision_recall_f1_score_multiclass():13    # Test Precision Recall and F1 Score for multiclass classification task14    y_true, y_pred, _ = make_prediction(binary=False)15 16    # compute scores with default labels introspection17    p, r, f, s = precision_recall_fscore_support(y_true, y_pred, average=None)18    assert_array_almost_equal(p, [0.83, 0.33, 0.42], 2)19    assert_array_almost_equal(r, [0.79, 0.09, 0.90], 2)20    assert_array_almost_equal(f, [0.81, 0.15, 0.57], 2)21    assert_array_equal(s, [24, 31, 20])22 23    # averaging tests24    ps = precision_score(y_true, y_pred, pos_label=1, average="micro")25    assert_array_almost_equal(ps, 0.53, 2)26 27    rs = recall_score(y_true, y_pred, average="micro")28    assert_array_almost_equal(rs, 0.53, 2)29 30    fs = f1_score(y_true, y_pred, average="micro")31    assert_array_almost_equal(fs, 0.53, 2)32 33    ps = precision_score(y_true, y_pred, average="macro")34    assert_array_almost_equal(ps, 0.53, 2)35 36    rs = recall_score(y_true, y_pred, average="macro")37    assert_array_almost_equal(rs, 0.60, 2)38 39    fs = f1_score(y_true, y_pred, average="macro")40    assert_array_almost_equal(fs, 0.51, 2)41 42    ps = precision_score(y_true, y_pred, average="weighted")43    assert_array_almost_equal(ps, 0.51, 2)44 45    rs = recall_score(y_true, y_pred, average="weighted")46    assert_array_almost_equal(rs, 0.53, 2)47 48    fs = f1_score(y_true, y_pred, average="weighted")49    assert_array_almost_equal(fs, 0.47, 2)50 51    with pytest.raises(ValueError):52        precision_score(y_true, y_pred, average="samples")53    with pytest.raises(ValueError):54        recall_score(y_true, y_pred, average="samples")55    with pytest.raises(ValueError):56        f1_score(y_true, y_pred, average="samples")57    with pytest.raises(ValueError):58        fbeta_score(y_true, y_pred, average="samples", beta=0.5)59 60    # same prediction but with and explicit label ordering61    p, r, f, s = precision_recall_fscore_support(62        y_true, y_pred, labels=[0, 2, 1], average=None63    )64    assert_array_almost_equal(p, [0.83, 0.41, 0.33], 2)65    assert_array_almost_equal(r, [0.79, 0.90, 0.10], 2)66    assert_array_almost_equal(f, [0.81, 0.57, 0.15], 2)67    assert_array_equal(s, [24, 20, 31])68 69 70@pytest.mark.parametrize("average", ["samples", "micro", "macro", "weighted", None])71def test_precision_refcall_f1_score_multilabel_unordered_labels(average):72    # test that labels need not be sorted in the multilabel case73    y_true = np.array([[1, 1, 0, 0]])74    y_pred = np.array([[0, 0, 1, 1]])75    p, r, f, s = precision_recall_fscore_support(76        y_true, y_pred, labels=[3, 0, 1, 2], warn_for=[], average=average77    )78    assert_array_equal(p, 0)79    assert_array_equal(r, 0)80    assert_array_equal(f, 0)81    if average is None:82        assert_array_equal(s, [0, 1, 1, 0])83 84 85def test_precision_recall_f1_score_binary_averaged():86    y_true = np.array([0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1])87    y_pred = np.array([1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1])88 89    # compute scores with default labels introspection90    ps, rs, fs, _ = precision_recall_fscore_support(y_true, y_pred, average=None)91    p, r, f, _ = precision_recall_fscore_support(y_true, y_pred, average="macro")92    assert p == np.mean(ps)93    assert r == np.mean(rs)94    assert f == np.mean(fs)95    p, r, f, _ = precision_recall_fscore_support(y_true, y_pred, average="weighted")96    support = np.bincount(y_true)97    assert p == np.average(ps, weights=support)98    assert r == np.average(rs, weights=support)99    assert f == np.average(fs, weights=support)100 101 102def test_zero_precision_recall():103    # Check that pathological cases do not bring NaNs104 105    old_error_settings = np.seterr(all="raise")106 107    try:108        y_true = np.array([0, 1, 2, 0, 1, 2])109        y_pred = np.array([2, 0, 1, 1, 2, 0])110 111        assert_almost_equal(precision_score(y_true, y_pred, average="macro"), 0.0, 2)112        assert_almost_equal(recall_score(y_true, y_pred, average="macro"), 0.0, 2)113        assert_almost_equal(f1_score(y_true, y_pred, average="macro"), 0.0, 2)114 115    finally:116        np.seterr(**old_error_settings)117 118 119def test_confusion_matrix_multiclass_subset_labels():120    # Test confusion matrix - multi-class case with subset of labels121    y_true, y_pred, _ = make_prediction(binary=False)122 123    # compute confusion matrix with only first two labels considered124    cm = confusion_matrix(y_true, y_pred, labels=[0, 1])125    assert_array_equal(cm, [[19, 4], [4, 3]])126 127    # compute confusion matrix with explicit label ordering for only subset128    # of labels129    cm = confusion_matrix(y_true, y_pred, labels=[2, 1])130    assert_array_equal(cm, [[18, 2], [24, 3]])131 132    # a label not in y_true should result in zeros for that row/column133    extra_label = np.max(y_true) + 1134    cm = confusion_matrix(y_true, y_pred, labels=[2, extra_label])135    assert_array_equal(cm, [[18, 0], [0, 0]])136 137 138@pytest.mark.parametrize(139    "labels, err_msg",140    [141        ([], "'labels' should contains at least one label."),142        ([3, 4], "At least one label specified must be in y_true"),143    ],144    ids=["empty list", "unknown labels"],145)146def test_confusion_matrix_error(labels, err_msg):147    y_true, y_pred, _ = make_prediction(binary=False)148    with pytest.raises(ValueError, match=err_msg):149        confusion_matrix(y_true, y_pred, labels=labels)150 151 152@pytest.mark.parametrize(153    "labels", (None, [0, 1], [0, 1, 2]), ids=["None", "binary", "multiclass"]154)155def test_confusion_matrix_on_zero_length_input(labels):156    expected_n_classes = len(labels) if labels else 0157    expected = np.zeros((expected_n_classes, expected_n_classes), dtype=int)158    cm = confusion_matrix([], [], labels=labels)159    assert_array_equal(cm, expected)160 161 162def test_confusion_matrix_dtype():163    y = [0, 1, 1]164    weight = np.ones(len(y))165    # confusion_matrix returns int64 by default166    cm = confusion_matrix(y, y)167    assert cm.dtype == np.int64168    # The dtype of confusion_matrix is always 64 bit169    for dtype in [np.bool_, np.int32, np.uint64]:170        cm = confusion_matrix(y, y, sample_weight=weight.astype(dtype, copy=False))171        assert cm.dtype == np.int64172    for dtype in [np.float32, np.float64, None, object]:173        cm = confusion_matrix(y, y, sample_weight=weight.astype(dtype, copy=False))174        assert cm.dtype == np.float64175 176    # np.iinfo(np.uint32).max should be accumulated correctly177    weight = np.full(len(y), 4294967295, dtype=np.uint32)178    cm = confusion_matrix(y, y, sample_weight=weight)179    assert cm[0, 0] == 4294967295180    assert cm[1, 1] == 8589934590181 182    # np.iinfo(np.int64).max should cause an overflow183    weight = np.full(len(y), 9223372036854775807, dtype=np.int64)184    cm = confusion_matrix(y, y, sample_weight=weight)185    assert cm[0, 0] == 9223372036854775807186    assert cm[1, 1] == -2187 188 189@pytest.mark.parametrize("dtype", ["Int64", "Float64", "boolean"])190def test_confusion_matrix_pandas_nullable(dtype):191    """Checks that confusion_matrix works with pandas nullable dtypes.192 193    Non-regression test for gh-25635.194    """195    pd = pytest.importorskip("pandas")196 197    y_ndarray = np.array([1, 0, 0, 1, 0, 1, 1, 0, 1])198    y_true = pd.Series(y_ndarray, dtype=dtype)199    y_predicted = pd.Series([0, 0, 1, 1, 0, 1, 1, 1, 1], dtype="int64")200 201    output = confusion_matrix(y_true, y_predicted)202    expected_output = confusion_matrix(y_ndarray, y_predicted)203 204    assert_array_equal(output, expected_output)205 206 207def test_classification_report_multiclass():208    # Test performance report209    iris = datasets.load_iris()210    y_true, y_pred, _ = make_prediction(dataset=iris, binary=False)211 212    # print classification report with class names213    expected_report = """\214              precision    recall  f1-score   support215 216      setosa       0.83      0.79      0.81        24217  versicolor       0.33      0.10      0.15        31218   virginica       0.42      0.90      0.57        20219 220    accuracy                           0.53        75221   macro avg       0.53      0.60      0.51        75222weighted avg       0.51      0.53      0.47        75223"""224    report = classificatio