area
price Currency status Resale
location
Moshi
1000
3500000
NaN
1.0
NaN
Lohegaon
6000
15600000
NaN
1.0
NaN
Hinjawadi
Village
11000
27500000
NaN
1.0
NaN
Shivaji
Nagar
5500 120000000
NaN
1.0
NaN
Hinjawadi
Village
1076
2050000
NaN
1.0
NaN
...
...
...
...
...
..
Wakad
1079
2100000
NaN
NaN
NaN
df["area"].value_counts()
1000 914
2000 103
3000 66
1200 62
1500 54
...
1420 1
1025 1
1190 1
1145 1
1766 1
Name: area, Length: 248, dtype: int64
maydoni boyicha uchastkani qidirish
m = df[df['area']<2000]
m
3/15/23, 1:15 PM
Axb'tayev Ilhom, 1-modul.ipynb - Colaboratory
https://colab.research.google.com/drive/1_-PcvWccN8nxicLlIxeh4OItWW-_YbkP#scrollTo=dsBUxZq9VSb7&printMode=true
4/8
area
price Currency status Resale
location
Moshi
1000
3500000
NaN
1.0
NaN
Hinjawadi
Village
1076
2050000
NaN
1.0
NaN
Yewalewadi 1076
421000
NaN
1.0
NaN
kesnand
1000
1100000
NaN
1.0
NaN
Alandi
1100
2000000
NaN
1.0
NaN
...
...
...
...
...
...
Wakad
1079
2100000
NaN
NaN
NaN
m.corrwith(m['price'])
area 0.221277
price 1.000000
Currency NaN
status -0.293574
Resale NaN
price_negotiable -0.068829
security_deposit NaN
furnished NaN
age of property -0.008103
Lift(s) 0.360173
Full Power Backup 0.410206
24 X 7 Security -0.000778
Children's play area 0.091473
Club House 0.093226
Gymnasium 0.051352
Swimming Pool 0.034907
Sports Facility 0.217334
Jogging Track -0.005214
Landscaped Gardens 0.150164
locality_score 0.060065
project_score 0.658843
builder_experience -0.752674
Multipurpose Room NaN
Intercom NaN
Maintenance Staff NaN
Car Parking NaN
Rain Water Harvesting NaN
Vaastu Compliant NaN
Indoor Games NaN
Golf Course NaN
Cafeteria NaN
ATM NaN
Hospital NaN
School NaN
Shopping Mall NaN
Staff Quarter NaN
dtype: float64
x=m["area"].to_numpy()
print(x)
y=m["price"].to_numpy()
print(y)
[1000 1076 1076 ... 1076 1170 1766]
[ 3500000 2050000 421000 ... 2299412 11500000 3100000]
3/15/23, 1:15 PM
Axb'tayev Ilhom, 1-modul.ipynb - Colaboratory
https://colab.research.google.com/drive/1_-PcvWccN8nxicLlIxeh4OItWW-_YbkP#scrollTo=dsBUxZq9VSb7&printMode=true
5/8
Tanlagan ustunlar orasida chiziqli bog'liqlik borligini aniqlab oldik uni vizual ko'rinishda ko'rib olamiz.
import matplotlib.pyplot as plt
import seaborn as sns
%matplotlib inline
plt.figure(figsize=(20,8))
sns.scatterplot(data=m, x="area",y="price")
plt.show()
plt.figure(figsize=(20,8))
sns.regplot(data=m, x="area",y="price", line_kws={"color":"r"})
plt.show()
3/15/23, 1:15 PM
Axb'tayev Ilhom, 1-modul.ipynb - Colaboratory
https://colab.research.google.com/drive/1_-PcvWccN8nxicLlIxeh4OItWW-_YbkP#scrollTo=dsBUxZq9VSb7&printMode=true
6/8
Sizning vazifangiz yuqoridagi X va Y o'zgaruvchilardan quyidagi formuladan foydalangan xolda θ 0 va θ 1 koe sientlarni hisoblash.
tetta1=np.sum(np.multiply((x-x.mean()),(y-y.mean())))/(np.sum(np.square(x-x.mean())))
tetta1
1463.4020905352188
tetta0=y.mean()-tetta1*x.mean()
tetta0
-220289.173956417
y_pridect=tetta0+x_train*tetta1
y_pridect_int=y_pridect.astype(np.int32)
y_pridect_int[0:1565]
array([1243112, 1535793, 1243112, 1243112, 1974813, 1243112, 1243112,
1243112, 1348477, 1354331, 1243112, 1535793, 1243112, 1243112,
1243112, 1243112, 1243112, 1243112, 1243112, 1974813, 1243112,
1243112, 1272380, 1243112, 1243112, 2560174, 1243112, 1243112,
1243112, 2340664, 1243112, 1243112, 1704084, 1243112, 1243112,
1243112, 1354331, 1243112, 1828473, 1243112, 2574808, 1354331,
1389453, 1243112, 1243112, 1243112, 1243112, 1243112, 1535793,
2121154, 1243112, 1243112, 2121154, 1243112, 1243112, 1243112,
1243112, 1243112, 1354331, 1535793, 1243112, 1354331, 1243112,
1243112, 1243112, 1243112, 1243112, 1243112, 1974813, 1243112,
1243112, 1243112, 1243112, 1243112, 2141641, 1243112, 1243112,
1243112, 1354331, 1243112, 1243112, 1243112, 1243112, 1243112,
1243112, 2238226, 1368965, 1243112, 1243112, 1354331, 1243112,
2121154, 1243112, 1608963, 1243112, 1243112, 1243112, 1243112,
1480184, 1895790, 1243112, 1243112, 2143105, 1243112, 1241649,
1243112, 2194324, 1243112, 1243112, 1243112, 1243112, 1611890,
1974813, 1243112, 1243112, 1243112, 1243112, 2121154, 1243112,
1243112, 1243112, 1243112, 1243112, 1244576, 1243112, 1243112,
1243112, 1243112, 1828473, 1272380, 1243112, 1243112, 2560174,
1354331, 1243112, 1243112, 1243112, 2413834, 1243112, 1354331,
1243112, 1243112, 1243112, 1243112, 1325063, 951895, 1243112,
1243112, 1535793, 1243112, 1243112, 1682133, 1243112, 1243112,
1974813, 1243112, 1243112, 1243112, 1243112, 1243112, 1243112,
1243112, 1243112, 2121154, 1755303, 2062618, 2377249, 2633344,
1243112, 1243112, 1243112, 1243112, 1243112, 1243112, 1243112,
1243112, 2121154, 1243112, 1243112, 1354331, 1974813, 1243112,
2238226, 1243112, 1316283, 1828473, 1535793, 1243112, 1243112,
1243112, 1243112, 1241649, 1243112, 1243112, 1243112, 1243112,
1243112, 1243112, 1243112, 1243112, 1243112, 1243112, 1535793,
1243112, 1243112, 1535793, 1243112, 2121154, 2047984, 1243112,
1243112, 2633344, 1243112, 1243112, 1243112, 1243112, 1243112,
1243112, 1243112, 1974813, 1243112, 2413834, 2194324, 1243112,
1243112, 1243112, 1243112, 1243112, 1243112, 1243112, 1973350,
511411, 1418721, 1389453, 1243112, 1243112, 1243112, 1243112,
1243112, 1243112, 1243112, 1243112, 1243112, 1243112, 1243112,
1243112, 1243112, 1243112, 1535793, 2047984, 1608963, 1243112,
1462623, 1243112, 1243112, 1535793, 965066, 2121154, 1243112,
1535793, 1243112, 1974813, 1243112, 1243112, 1241649, 1243112,
1243112, 1243112, 1535793, 1243112, 1244576, 1389453, 1243112,
1243112, 1243112, 1243112, 2487004, 1243112, 2611393, 1243112,
1608963, 1243112, 1243112, 1243112, 1243112, 1243112, 1243112,
1535793, 1243112, 1243112, 1243112, 1755303, 2194324, 1243112,
1243112, 1243112, 2413834, 1243112, 1243112, 2633344, 1243112,
1243112, 1243112, 2413834, 1243112, 1243112, 1243112, 2238226,
2677246, 1623597, 1608963, 1243112, 1535793, 1974813, 1243112,
1243112, 1535793, 1243112, 1243112, 1243112, 1243112, 1243112,
1243112, 2238226, 2428468, 1243112, 1243112, 1243112, 897750,
3/15/23, 1:15 PM
Axb'tayev Ilhom, 1-modul.ipynb - Colaboratory
https://colab.research.google.com/drive/1_-PcvWccN8nxicLlIxeh4OItWW-_YbkP#scrollTo=dsBUxZq9VSb7&printMode=true
7/8
1243112, 1243112, 1243112, 1243112, 1354331, 1243112, 1521159,
1243112, 1769937, 1243112, 1243112, 1243112, 1535793, 1243112,
1974813, 1354331, 1243112, 2511882, 1243112, 1243112, 1535793,
1535793, 1828473, 1243112, 1462623, 1243112, 1243112, 1243112,
1244576, 2238226, 1535793, 1974813, 1535793, 1535793, 1243112,
1243112, 1243112, 1828473, 1243112, 1243112, 1243112, 1243112,
1243112, 1769937, 1243112, 1243112, 1243112, 1243112, 1243112,
1974813, 1243112, 1974813, 1243112, 1243112, 1243112, 1243112,
1243112, 2004082, 1243112, 1096772, 1243112, 1535793, 1243112,
2413834, 1828473, 1243112, 1243112, 1534329, 1389453, 1974813,
1535793
1535793
2450419
1243112
1260673
1243112
1243112
plt.figure(figsize=(20,8))
sns.scatterplot(data=m, x="area",y="price")
plt.plot(x_train,y_pridect_int, color="r")
plt.show()
total=pd.Series(y_pridect_int)
total
0 1243112
1 1535793
2 1243112
3 1243112
4 1974813
...
484 1243112
485 1243112
486 1974813
487 1243112
488 1243112
Length: 489, dtype: int32
m['Total_price']=total
m
3/15/23, 1:15 PM
Axb'tayev Ilhom, 1-modul.ipynb - Colaboratory
https://colab.research.google.com/drive/1_-PcvWccN8nxicLlIxeh4OItWW-_YbkP#scrollTo=dsBUxZq9VSb7&printMode=true
8/8
:1: SettingWithCopyWa
A value is trying to be set on a copy of a slice fro
Try using .loc[row_indexer,col_indexer] = value inst
See the caveats in the documentation:
https://pandas
m['Total_price']=total
area
price Currency status Resale
location
Moshi
1000
3500000
NaN
1.0
NaN
Hinjawadi
Village
1076
2050000
NaN
1.0
NaN
Yewalewadi 1076
421000
NaN
1.0
NaN
kesnand
1000
1100000
NaN
1.0
NaN
Alandi
1100
2000000
NaN
1.0
NaN
plt.figure(figsize=(20,8))
plt.grid()
sns.lineplot(data=m[["price","Total_price"]])
plt.title("Farqi")
plt.show()
Dostları ilə paylaş: |