## [Hindi] Linear Regression Code In Python Sklearn! – Machine Learning Tutorials In Hindi

This video is a part of my Machine Learning Using Python Playlist – https://www.youtube.com/playlist?list=PLu0W_9lII9ai6fAMHp-acBmJONT7Y4BSG

Best Hindi Videos For Learning Programming:

►Learn Python In One Video – https://www.youtube.com/watch?v=qHJjMvHLJdg

►Learn JavaScript in One Video – https://www.youtube.com/watch?v=onbBV0uFVpo

►Learn PHP In One Video – https://www.youtube.com/watch?v=xW7ro3lwaCI

►Machine Learning Using Python – https://www.youtube.com/playlist?list=PLu0W_9lII9ai6fAMHp-acBmJONT7Y4BSG

►Creating & Hosting A Website (Tech Blog) Using Python – https://www.youtube.com/playlist?list=PLu0W_9lII9agAiWp6Y41ueUKx1VcTRxmf

►Object Oriented Programming In Python – https://www.youtube.com/playlist?list=PLu0W_9lII9ahfRrhFcoB-4lpp9YaBmdCP

►Python Data Science and Big Data Tutorials – https://www.youtube.com/playlist?list=PLu0W_9lII9agK8pojo23OHiNz3Jm6VQCH

►Website (created using Flask) – https://www.codewithharry.com
►Instagram – https://www.instagram.com/CodeWithHarry/

Source

### Comment List

• CodeWithHarry
January 11, 2021

#Code
import matplotlib.pyplot as plt
import numpy as np
from sklearn import datasets, linear_model
from sklearn.metrics import mean_squared_error

diabetes_X = diabetes.data

diabetes_X_train = diabetes_X[:-30]
diabetes_X_test = diabetes_X[-30:]

diabetes_y_train = diabetes.target[:-30]
diabetes_y_test = diabetes.target[-30:]

model = linear_model.LinearRegression()

model.fit(diabetes_X_train, diabetes_y_train)

diabetes_y_predicted = model.predict(diabetes_X_test)

print("Mean squared error is: ", mean_squared_error(diabetes_y_test, diabetes_y_predicted))

print("Weights: ", model.coef_)
print("Intercept: ", model.intercept_)

# plt.scatter(diabetes_X_test, diabetes_y_test)
# plt.plot(diabetes_X_test, diabetes_y_predicted)
#
# plt.show()

# Mean squared error is: 3035.0601152912695
# Weights: [941.43097333]
# Intercept: 153.39713623331698

• CodeWithHarry
January 11, 2021

From 945 to 945k subscribers in 2 years ♥️

• CodeWithHarry
January 11, 2021

dataset kha sa lena ha link dede

• CodeWithHarry
January 11, 2021

excellent session

• CodeWithHarry
January 11, 2021

In one Sentence !! God is TEACHING US !!

• CodeWithHarry
January 11, 2021

ausome sir all clear

• CodeWithHarry
January 11, 2021

at 9:00 i think u messed up the slicing. diabetes_x_train[:-30] does not give last 30 elements. when i check shape it shows (412,1) elements. that means everything except last 30 elements and diabetes_x_train[-20:] means last 20 elements

• CodeWithHarry
January 11, 2021

ye bhi theek hai

• CodeWithHarry
January 11, 2021

Sir help me
Here an error occured while using matplotlib
So what to do now

• CodeWithHarry
January 11, 2021

aaj se roj dekhna hai isse

• CodeWithHarry
January 11, 2021

Great brother love from pakistan

• CodeWithHarry
January 11, 2021

You are a legend.

• CodeWithHarry
January 11, 2021

25:32

bhaiya ekdum santusht hain!!

thanku very much!!

• CodeWithHarry
January 11, 2021

Awesome, keep it up Harry…Geo

• CodeWithHarry
January 11, 2021

869 subs to 849 k subs ,
Great Journey

• CodeWithHarry
January 11, 2021

great video

• CodeWithHarry
January 11, 2021

Can I do this in Sublime ??

• CodeWithHarry
January 11, 2021

What are weights???

• CodeWithHarry
January 11, 2021

Thank you so much harry sir, you really teach very Nicely and love your videos and i have learned a lot

• CodeWithHarry
January 11, 2021

900 to 800k subscribers.

• CodeWithHarry
January 11, 2021

Extra talkative, it's sooo annoying literally

• CodeWithHarry
January 11, 2021

Mujhe ei error a raha hai.. iska solution kya hoga mujhe kahi or nehi mila

diabetes_x_train = diabetes_x[:,-30]

diabetes_x_test = diabetes_x[-30:]

diabetes_y_train = diabetes.target[:,30]

diabetes_y_test = diabetes.target[-30,:]

model = linear_model.LinearRegression()

model.fit(diabetes_x_train,diabetes_y_train)

diabetes_y_predict = model.predict(diabetes_x_test)

mean_squared_error(diabetes_y_test ,diabetes_y_predict)

============== ERROR==========================

IndexError Traceback (most recent call last)

<ipython-input-17-b0290405a178> in <module>

—-> 1 diabetes_x_train = diabetes_x[:,-30]

2 diabetes_x_test = diabetes_x[-30:]

3

4

5

IndexError: index -30 is out of bounds for axis 1 with size 1

• CodeWithHarry
January 11, 2021

ImportError: DLL load failed while importing ft2font: The specified module could not be found.
i am doing in vs code and its giving this error, how to fix it ?

• CodeWithHarry
January 11, 2021

diabetes_x = diabetes.data[:,np.newaxis,2]
In this line what is the meaning of np.newaxis?

• CodeWithHarry
January 11, 2021

I observed that there were only 965 subscribers when you were recording this video… and the number has crosses 7L in just 2 years… this shows your talent your hard work and and your determination towards your work. thanks a lot sir, for helping us grow… 🙂

• CodeWithHarry
January 11, 2021

Simply wowww… great explaination 👍👍 and thanks a lot for the code.

• CodeWithHarry
January 11, 2021

Ye scattering excel me bhi kar sakte h na carry bhai?

• CodeWithHarry
January 11, 2021

superb video sir,love youuuuuu sir

• CodeWithHarry
January 11, 2021

Hello bhai, thank you for sharing knowledge of python.
May I know what is a road map for data analysis.
Like first is EDA then after EDA what other analysis we can perform.

• CodeWithHarry
January 11, 2021

Thanks sir. You are really a great and intelligent person.

• CodeWithHarry
January 11, 2021

Sir ye error aa raha hai
ImportError: cannot import name '__check_build' from 'sklearn'

• CodeWithHarry
January 11, 2021

In am tired for saying go you… That is make adjustments video in jupyter notebook but you don't made what is problem… For beginner jupyter is very useful

• CodeWithHarry
January 11, 2021

Bilkul santusht hai guruji

• CodeWithHarry
January 11, 2021

ImportError: DLL load failed while importing ft2font: The specified module could not be found.

• CodeWithHarry
January 11, 2021

Mza aa gya bhai

• CodeWithHarry
January 11, 2021

great

• CodeWithHarry
January 11, 2021

really nice bro till now!!

• CodeWithHarry
January 11, 2021

Sir why you have not defined diabetes_y as you have defined diabetes_x =diabetes.data[:, np.newaxis, 2] ??

• CodeWithHarry
January 11, 2021

bhai yeh snowall k orginal mic kah s liya

• CodeWithHarry
January 11, 2021

Please make a course on Graphic Design

• CodeWithHarry
January 11, 2021

TypeError: fit() missing 1 required positional argument: 'y' this error is showing what i hould do

• CodeWithHarry
January 11, 2021

Sir mene bhut kuch sikha apse

• CodeWithHarry
January 11, 2021

Value error: x and y must be the same size, it is same size I copy your source code then also it's give me bug.

• CodeWithHarry
January 11, 2021

Using [:,-30] would pick first thirty elements when there are 60 elements in the whole array

• CodeWithHarry
January 11, 2021

I do not understand why we used[:-30] for first thirty elements instead I think we should use[:,30]