Python Mind Map
Copyright By PowCoder代写 加微信 powcoder
Python Django – MVT Pattern
MVC stands for Model-View-Controller. We use this when we want to develop applications with user interfaces. MVT stands for Model-View-Template.
A template is an HTML file mixed with DTL (Django Template Language).
Django takes care of the Controller part, which is the software code and controls the interaction
between the other two parts- Model and View.
When a user requests for a resource, Django acts as a controller and checks if it is available. If the URL maps, View interacts with the Model and renders a Template. Python Django sends back a Template to the user as a response.
The model helps us handle database. View executes business logic and interacts with Model to carry data.
It also renders Template. Template handles the user interface and is a presentation layer.
The Model class holds essential fields and methods. For each model class, we have a table in the database.
Model is a subclass of django.db.models.Model. Each field here denotes a database field. With Django, we have a database-abstraction API that lets us perform CRUD (Create-Retrieve- Update-Delete) operations on mapped tables.
1. Scalability
When you need to scale your system, you can simply add more web nodes to your Django. That is, you can scale it horizontally. Two products that use Django’s scalability are Disqus and Instagram.
2. Portability
The portability of Python makes for a portable Django too. Various platforms include Windows, Linux, and MacOS.
3. Security
Python Django ensures some arrangements for security too. One of these is that it stores hashed passwords in cookies.
4. Versatility
Python Django will work with formats like HTML, JSON, XML, among others. It also supports many different client-side frameworks.
So, we can use it to build anything including regular websites and social networks.
5. Packages
Django Programming has the foundation of thousands of additional packages.
6. Ease of Use
Features like the built-in admin interface make it easy to build with Django. It is also fully functional and finds it easy to switch databases.
Python Machine Learning
p-value for a statistical model is the probability that when the null hypothesis is true, the statistical summary is equal to or greater than the actual observed results. This is also termed ‘probability value’ or ‘asymptotic significance’.
It also talks about two samples- whether they’re different. In other words, it gives us the probability of difference between populations. The test involves a t-statistic. For small samples, we can use a T-test with two samples.
Consider the voting populace in India and in Gujarat. Does the average age of Gujarati voters differ from that of the population?
import numpy as np
import pandas as pd
import scipy.stats as stats
import matplotlib.pyplot as plt
import math
np.random.seed(6)
population_ages1=stats.poisson.rvs(loc=18,mu=35,size=150000)
population_ages2=stats.poisson.rvs(loc=18,mu=10,size=100000)
population_ages=np.concatenate((population_ages1,population_ages2))
gujarat_ages1=stats.poisson.rvs(loc=18,mu=30,size=30)
gujarat_ages2=stats.poisson.rvs(loc=18,mu=10,size=20)
gujarat_ages=np.concatenate((gujarat_ages1,gujarat_ages2))
population_ages.mean()
gujarat_ages.mean()
stats.ttest_1samp(a=gujarat_ages,popmean=population_ages.mean())
Two-sample T-test With Python
np.random.seed(12)
maharashtra_ages1=stats.poisson.rvs(loc=18,mu=33,size=30)
maharashtra_ages2=stats.poisson.rvs(loc=18,mu=13,size=20)
maharashtra_ages=np.concatenate((maharashtra_ages1,maharashtra_ages2))
maharashtra_ages.mean()
stats.ttest_ind(a=gujarat_ages,b=maharashtra_ages,equal_var=False)
Paired T-test With Python
np.random.seed(11)
before=stats.norm.rvs(scale=30,loc=250,size=100)
after=before+stats.norm.rvs(scale=5,loc=-1.25,size=100)
weight_df=pd.DataFrame({“weight_before”:before,
“weight_after”:after,
“weight_change”:after-before})
weight_df.describe()
stats.ttest_rel(a=before,b=after)
KS Test in Python Statistics
stats.kstest(x,’t’,(10,))
stats.kstest(x,’norm’)
#two samples
stats.ks_2samp(gujarat_ages,maharashtra_ages)
Correlation In Python
df=pd.read_csv(‘furniture.csv’,index_col=’Serial’,parse_dates=True)
df[‘Gross’]=df.Cost+df.Cost*10
df.describe()
import seaborn as sn
df1=sn.load_dataset(‘iris’)
sn.pairplot(df,kind=’scatter’)
Machine Learning Algorithms
Linear Regression Logistic Regression
Decision Tree
Naive Bayes
Artificial Neural Networks K-means Clustering
Anomaly Detection
Gaussian Mixture Model Principal Component Analysis KNN
Support Vector Machines
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com