Skip to content

Commit db342d1

Browse files
committed
Simple Linear Regression
1 parent 804a7f8 commit db342d1

File tree

3 files changed

+358
-34
lines changed

3 files changed

+358
-34
lines changed

Salary_Data.csv

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
YearsExperience,Salary
2+
1.1,39343.00
3+
1.3,46205.00
4+
1.5,37731.00
5+
2.0,43525.00
6+
2.2,39891.00
7+
2.9,56642.00
8+
3.0,60150.00
9+
3.2,54445.00
10+
3.2,64445.00
11+
3.7,57189.00
12+
3.9,63218.00
13+
4.0,55794.00
14+
4.0,56957.00
15+
4.1,57081.00
16+
4.5,61111.00
17+
4.9,67938.00
18+
5.1,66029.00
19+
5.3,83088.00
20+
5.9,81363.00
21+
6.0,93940.00
22+
6.8,91738.00
23+
7.1,98273.00
24+
7.9,101302.00
25+
8.2,113812.00
26+
8.7,109431.00
27+
9.0,105582.00
28+
9.5,116969.00
29+
9.6,112635.00
30+
10.3,122391.00
31+
10.5,121872.00

practice.ipynb

+108-34
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
"cell_type": "code",
55
"execution_count": null,
66
"metadata": {
7-
"colab": {
8-
"background_save": true
9-
},
107
"id": "qZxQqAVRE6SL"
118
},
129
"outputs": [],
@@ -23,7 +20,7 @@
2320
},
2421
{
2522
"cell_type": "code",
26-
"execution_count": 9,
23+
"execution_count": 1,
2724
"metadata": {
2825
"id": "i6HqgvA6FEp4"
2926
},
@@ -36,14 +33,14 @@
3633
},
3734
{
3835
"cell_type": "code",
39-
"execution_count": 10,
36+
"execution_count": 2,
4037
"metadata": {
4138
"colab": {
4239
"base_uri": "https://localhost:8080/",
4340
"height": 206
4441
},
4542
"id": "9k_z8bRmFTvQ",
46-
"outputId": "c506a738-f85a-4510-e0af-94c337163485"
43+
"outputId": "e6b7bae5-b03e-4851-f024-72822487848c"
4744
},
4845
"outputs": [
4946
{
@@ -59,7 +56,7 @@
5956
],
6057
"text/html": [
6158
"\n",
62-
" <div id=\"df-405b7ffb-cc5e-452a-963f-910d12061009\" class=\"colab-df-container\">\n",
59+
" <div id=\"df-fe0010d2-1744-4911-8133-7f1574a1a950\" class=\"colab-df-container\">\n",
6360
" <div>\n",
6461
"<style scoped>\n",
6562
" .dataframe tbody tr th:only-of-type {\n",
@@ -126,7 +123,7 @@
126123
" <div class=\"colab-df-buttons\">\n",
127124
"\n",
128125
" <div class=\"colab-df-container\">\n",
129-
" <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-405b7ffb-cc5e-452a-963f-910d12061009')\"\n",
126+
" <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-fe0010d2-1744-4911-8133-7f1574a1a950')\"\n",
130127
" title=\"Convert this dataframe to an interactive table.\"\n",
131128
" style=\"display:none;\">\n",
132129
"\n",
@@ -178,12 +175,12 @@
178175
"\n",
179176
" <script>\n",
180177
" const buttonEl =\n",
181-
" document.querySelector('#df-405b7ffb-cc5e-452a-963f-910d12061009 button.colab-df-convert');\n",
178+
" document.querySelector('#df-fe0010d2-1744-4911-8133-7f1574a1a950 button.colab-df-convert');\n",
182179
" buttonEl.style.display =\n",
183180
" google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
184181
"\n",
185182
" async function convertToInteractive(key) {\n",
186-
" const element = document.querySelector('#df-405b7ffb-cc5e-452a-963f-910d12061009');\n",
183+
" const element = document.querySelector('#df-fe0010d2-1744-4911-8133-7f1574a1a950');\n",
187184
" const dataTable =\n",
188185
" await google.colab.kernel.invokeFunction('convertToInteractive',\n",
189186
" [key], {});\n",
@@ -203,8 +200,8 @@
203200
" </div>\n",
204201
"\n",
205202
"\n",
206-
"<div id=\"df-611822fe-e12e-4369-9752-8cbfe739403e\">\n",
207-
" <button class=\"colab-df-quickchart\" onclick=\"quickchart('df-611822fe-e12e-4369-9752-8cbfe739403e')\"\n",
203+
"<div id=\"df-9cecff8c-2f40-492c-b542-c46c563370d2\">\n",
204+
" <button class=\"colab-df-quickchart\" onclick=\"quickchart('df-9cecff8c-2f40-492c-b542-c46c563370d2')\"\n",
208205
" title=\"Suggest charts\"\n",
209206
" style=\"display:none;\">\n",
210207
"\n",
@@ -323,7 +320,7 @@
323320
" }\n",
324321
" (() => {\n",
325322
" let quickchartButtonEl =\n",
326-
" document.querySelector('#df-611822fe-e12e-4369-9752-8cbfe739403e button');\n",
323+
" document.querySelector('#df-9cecff8c-2f40-492c-b542-c46c563370d2 button');\n",
327324
" quickchartButtonEl.style.display =\n",
328325
" google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
329326
" })();\n",
@@ -340,7 +337,7 @@
340337
}
341338
},
342339
"metadata": {},
343-
"execution_count": 10
340+
"execution_count": 2
344341
}
345342
],
346343
"source": [
@@ -350,7 +347,7 @@
350347
},
351348
{
352349
"cell_type": "code",
353-
"execution_count": 26,
350+
"execution_count": 3,
354351
"metadata": {
355352
"id": "r5v_kGw6XXEg"
356353
},
@@ -362,13 +359,13 @@
362359
},
363360
{
364361
"cell_type": "code",
365-
"execution_count": 27,
362+
"execution_count": 4,
366363
"metadata": {
367364
"colab": {
368365
"base_uri": "https://localhost:8080/"
369366
},
370367
"id": "XhSpBN94Xkur",
371-
"outputId": "0c7aa66d-399a-451d-dff3-4e65d8a4e0dd"
368+
"outputId": "96fdb237-23c7-412f-f198-6752e46673e1"
372369
},
373370
"outputs": [
374371
{
@@ -396,7 +393,7 @@
396393
},
397394
{
398395
"cell_type": "code",
399-
"execution_count": 28,
396+
"execution_count": 5,
400397
"metadata": {
401398
"id": "pTZ7q-2QXoR7"
402399
},
@@ -411,13 +408,13 @@
411408
},
412409
{
413410
"cell_type": "code",
414-
"execution_count": 29,
411+
"execution_count": 6,
415412
"metadata": {
416413
"colab": {
417414
"base_uri": "https://localhost:8080/"
418415
},
419416
"id": "FjMZNw7ldVTK",
420-
"outputId": "7edcf6af-ad31-4b60-cc4e-d8095c1372f5"
417+
"outputId": "5ecea752-e59f-49ad-91a0-ba989e91aa5d"
421418
},
422419
"outputs": [
423420
{
@@ -443,7 +440,7 @@
443440
},
444441
{
445442
"cell_type": "code",
446-
"execution_count": 30,
443+
"execution_count": 7,
447444
"metadata": {
448445
"id": "xSjiM9cV9mBt"
449446
},
@@ -466,9 +463,9 @@
466463
"base_uri": "https://localhost:8080/"
467464
},
468465
"id": "oU8IcBKBAaV_",
469-
"outputId": "0095c6f0-5f25-449e-cc34-2d375fea44c3"
466+
"outputId": "5d4203a5-392e-4d72-9aa4-b4da85ac70da"
470467
},
471-
"execution_count": 33,
468+
"execution_count": 8,
472469
"outputs": [
473470
{
474471
"output_type": "stream",
@@ -502,9 +499,9 @@
502499
"base_uri": "https://localhost:8080/"
503500
},
504501
"id": "0L_2yGdNBHY4",
505-
"outputId": "8222f326-8e8d-487b-c99d-7393e5775eca"
502+
"outputId": "42ee4663-2c98-486e-8098-f5b37c72ae7f"
506503
},
507-
"execution_count": 36,
504+
"execution_count": 9,
508505
"outputs": [
509506
{
510507
"output_type": "stream",
@@ -524,7 +521,7 @@
524521
"metadata": {
525522
"id": "dnTN_LTrDYNy"
526523
},
527-
"execution_count": 37,
524+
"execution_count": 10,
528525
"outputs": []
529526
},
530527
{
@@ -537,9 +534,9 @@
537534
"base_uri": "https://localhost:8080/"
538535
},
539536
"id": "lO5jJUL4EzE7",
540-
"outputId": "92f7f130-2e57-4496-891c-c0fd0a40d910"
537+
"outputId": "41745a01-33f3-414f-baa3-f40af4e68112"
541538
},
542-
"execution_count": 38,
539+
"execution_count": 11,
543540
"outputs": [
544541
{
545542
"output_type": "stream",
@@ -567,9 +564,9 @@
567564
"base_uri": "https://localhost:8080/"
568565
},
569566
"id": "OndO0tmhEzIh",
570-
"outputId": "526732b0-f3c5-48ca-817e-6afbf5f1f3c7"
567+
"outputId": "87093176-13f4-4cd6-f18e-3d2a34c64fdc"
571568
},
572-
"execution_count": 39,
569+
"execution_count": 12,
573570
"outputs": [
574571
{
575572
"output_type": "stream",
@@ -591,9 +588,9 @@
591588
"base_uri": "https://localhost:8080/"
592589
},
593590
"id": "JiRhwGDkEzMb",
594-
"outputId": "1ce21167-1560-495c-d9d5-988c8de69fbb"
591+
"outputId": "ca8863d6-ad00-415c-faa7-641c7a40b745"
595592
},
596-
"execution_count": 40,
593+
"execution_count": 13,
597594
"outputs": [
598595
{
599596
"output_type": "stream",
@@ -614,9 +611,9 @@
614611
"base_uri": "https://localhost:8080/"
615612
},
616613
"id": "13ot0Ju6EzQB",
617-
"outputId": "3da34b0b-dc26-4204-d752-dd5bc73a3869"
614+
"outputId": "04d3ba80-f6bc-4357-fca7-1f176ecbb671"
618615
},
619-
"execution_count": 41,
616+
"execution_count": 14,
620617
"outputs": [
621618
{
622619
"output_type": "stream",
@@ -626,6 +623,83 @@
626623
]
627624
}
628625
]
626+
},
627+
{
628+
"cell_type": "code",
629+
"source": [
630+
"from sklearn.preprocessing import StandardScaler\n",
631+
"sc = StandardScaler()\n",
632+
"x_train[:, 3:] = sc.fit_transform(x_train[:, 3:])\n",
633+
"x_test[:, 3:] = sc.transform(x_test[:, 3:])"
634+
],
635+
"metadata": {
636+
"id": "bhNuC8NbrpbR"
637+
},
638+
"execution_count": 16,
639+
"outputs": []
640+
},
641+
{
642+
"cell_type": "code",
643+
"source": [
644+
"print(x_train)"
645+
],
646+
"metadata": {
647+
"colab": {
648+
"base_uri": "https://localhost:8080/"
649+
},
650+
"id": "fjvq3PZArpdp",
651+
"outputId": "0a2d6ed6-7241-4c48-e788-ba2d80a8980a"
652+
},
653+
"execution_count": 17,
654+
"outputs": [
655+
{
656+
"output_type": "stream",
657+
"name": "stdout",
658+
"text": [
659+
"[[0.0 0.0 1.0 -0.1915918438457856 -1.0781259408412427]\n",
660+
" [0.0 1.0 0.0 -0.014117293757057902 -0.07013167641635401]\n",
661+
" [1.0 0.0 0.0 0.5667085065333239 0.6335624327104546]\n",
662+
" [0.0 0.0 1.0 -0.3045301939022488 -0.30786617274297895]\n",
663+
" [0.0 0.0 1.0 -1.901801144700799 -1.4204636155515822]\n",
664+
" [1.0 0.0 0.0 1.1475343068237056 1.2326533634535488]\n",
665+
" [0.0 1.0 0.0 1.4379472069688966 1.5749910381638883]\n",
666+
" [1.0 0.0 0.0 -0.7401495441200352 -0.5646194287757336]]\n"
667+
]
668+
}
669+
]
670+
},
671+
{
672+
"cell_type": "code",
673+
"source": [
674+
"print(x_test)"
675+
],
676+
"metadata": {
677+
"colab": {
678+
"base_uri": "https://localhost:8080/"
679+
},
680+
"id": "HuVLefVPrpf9",
681+
"outputId": "9cdda02b-4b8c-4c8b-9fec-32176840cf3a"
682+
},
683+
"execution_count": 18,
684+
"outputs": [
685+
{
686+
"output_type": "stream",
687+
"name": "stdout",
688+
"text": [
689+
"[[0.0 1.0 0.0 30.0 54000.0]\n",
690+
" [1.0 0.0 0.0 37.0 67000.0]]\n"
691+
]
692+
}
693+
]
694+
},
695+
{
696+
"cell_type": "code",
697+
"source": [],
698+
"metadata": {
699+
"id": "zY-92wIurpjn"
700+
},
701+
"execution_count": null,
702+
"outputs": []
629703
}
630704
],
631705
"metadata": {

0 commit comments

Comments
 (0)