Author Archives: Robins

Mac: how to show hidden files under Apple Mac operating system

There are many ways to display hidden files in MAC,

1. Terminal

The simplest is to enter commands on the MAC terminal.
Show hidden files (note space and case):

defaults write com.apple.finder AppleShowAllFiles -bool true 

or

defaults write com.apple.finder AppleShowAllFiles YES

Do not show hidden files:

defaults write com.apple.finder AppleShowAllFiles -bool false 

or

defaults write com.apple.finder AppleShowAllFiles NO

After input, click enter, then exit the terminal directly and restart finder.
Restart the finder: first force to exit the finder, and then restart the finder.

2. Shortcut key

    Press Shift + cmmand +. On the keyboard to hide the directory where the file is located, and then you can see that all the hidden files in the hidden folder with a small dot in front or the files with light blue are hidden files. In this way, you can view the hidden directory. To restore the hidden file, press Shift + cmmand +. Again to restore the hidden state of the file, as shown in Figure 2. The hidden file is no longer visible.

Sigmoid function

Sigmoid function is a mathematical function with beautiful S-shape curve, which is widely used in logistic regression and artificial neural network. The mathematical form of sigmoid function is:
0

f(x)=11+e−x

The function image is as follows:

It can be seen that sigmoid function is continuous, smooth, strictly monotone, and symmetric with (0,0.5) center, which is a very good threshold function.

When x approaches negative infinity, y approaches 0; when x approaches positive infinity, y approaches 1; when x = 0, y = 0.5. Of course, when x goes beyond the range of [- 6,6], the value of the function basically does not change, and the value is very close, so it is generally not considered in the application.

The range of sigmoid function is limited between (0,1). We know that [0,1] corresponds to the range of probability value, so sigmoid function can be associated with a probability distribution.

The derivative of sigmoid function is its own function, that is

f′(x)=f(x)(1−f(x))

The calculation is very convenient and time-saving. The derivation process is as follows:
according to the commonly used derivation formula,
is obtained

f′(x)=(−1)(1+e−x)−2(0+(−1)e−x)=e−x(1+e−x)2=e−x1+e−x11+e−x

And:

1−f(x)=1−11+e−x=e−x1+e−x

Therefore,

f′(x)=f(x)(1−f(x))

.

Although sigmoid function has good properties, it can be used in classification problems, such as the classifier of logistic regression model. But why choose this function? In addition to the above mathematical easier to deal with, there are its own derivation characteristics.
For the classification problem, especially for the binary classification problem, it is assumed that the distribution obeys Bernoulli distribution. The PMF of Bernoulli distribution is:
0

f(x|p)=px(1−p)1−x

According to《

The general expression framework of the family of exponential distributions is as follows

f(x|θ)=h(x)exp{η(θ)T(x)−A(θ)}

The Bernoulli distribution is transformed into:

f(x|p)=exp{ln(p1−p)x+log(1−p)}

Among them:

θ=p

h(x)=1

T(x)=x

η(θ)=lnp1−p

A(θ)=−ln(1−p)

. Therefore, Bernoulli distribution also belongs to exponential distribution family.

We can deduce it

p

And η (θ):
the relationship between η (θ) and η (θ) was analyzed

η(θ)=lnp1−p

Then:

−η(θ)=−lnp1−p=ln1−pp=ln(1p−1)

The results are as follows

e−η(θ)=1p−1

1+e−η(θ)=1p

p=11+e−η(θ)

This is the form of sigmoid function.

solve org.apache.ibatis . binding.BindingException : invalid bound statement (not found)

org.apache.ibatis . binding.BindingException : invalid bound statement (not found) problem, that is, there is a problem when the Dao interface and mapper configuration file are mapped and bound in mybatis. In short, the interface and XML are either not found, or they are found but not matched.

The screenshot shows the common reasons for searching in the network

According to the revision, the problem still exists. Finally, it took a lot of effort to find the root of the problem. Dao interface is inconsistent with the file name of XML.

The interface name and interface file name are both department Dao, and the configuration file name is DeparmentDao.xml It took a lot of effort to look up a t for both names. After modification, everything will be normal.

This is a point as like as two peas. Remember that the name of the interface name and Mybatis must be exactly the same.

How to use matlab to solve equation

How to use matlab to solve equation

1. Preface

As one of the three major mathematical software, Matlab is the best in numerical calculation. Solving equations is the most basic and common problem in engineering study and engineering calculation. It is very important to master the method of solving equations with modern tools to improve our engineering literacy. Therefore, this paper will introduce the method of solving equations in MATLAB.

2. Usage

solving process

2.1 – indicated variables

Tell the computer the variables contained in the equation, including parameters and unknown variables. For example, the equation to be solved is: obviously, there are symbolic variables a, B, C and X in the equation, so the writing method of this step is:

syms a b c x  

 

2.2 specify equations, unknowns and constraints (not required)

If there is more than one equation,

eqns put it in [] and separate it with a comma. For example:
vars unknowns to be solved
Names value (not required) Names: “return conditions” returns the general solution with parameters. ” If ‘true’ is returned and ‘false’ is not, a special solution is given;
Name: ‘ignoreanalytical constraints’ is the simplest form of the solution given. ‘true ‘is yes and’ false ‘is no
Name:’ principalvalue ‘only gives one solution. False is to return all solutions, true is to return only one solution;
Name: ‘real’ only returns real solutions

2.3 obtain the solution of the equation

If there are multiple functions, the solution is stored as a structure.

 

3. Specific examples

3.1 = general solution of sin (x) = 1

 

Specific code:

syms x  [x,params,conds]=solve(sin(x)==1,’ReturnConditions’, true) 

 

result

solx =pi/2+2*pi*k  params =k  conds =in(k,’integer’)

 

It can be seen that the general solution of the equation is as follows:

 

3.2 solve the following equation:

code:

syms a b c y x [x,y]=solve([a*x^2+b*y+c==0,a*x+2*y==4],[x,y])

 

result:

x =  ((a*b)/4-(-(a*(- a*b^2+32*b +16*c))/16)^(1/2))/a  ((a*b)/4+(-(a*(- a*b^2+32*b +16*c))/16)^(1/2))/a   y =  (-(a*(- a*b^2+32*b +16*c))/16)^(1/2)/2-(a*b)/8+2  2-(-(a*(- a*b^2+32*b +16*c))/16)^(1/2)/2-(a*b)/8

 

Namely:

Matlab matrix transpose function

For the known matrix A, matlab provides us with two transpose operations.

A. ‘non conjugate transpose

A ‘conjugate transpose

When a is a real matrix, they are the same

Simply conjugate with: conj ()

Simple transpose: transpose ()

example:

 

  a =

        12.0000                  0 + 2.0000i         5.0000          
        0                             5.0000               4.0000 

>> a’

             ans =

                      12.0000                  0          
                      0 – 2.0000i              5.0000          
                      5.0000                    4.0000         

>> a.’

           ans =

                   12.0000                  0          
                  0 + 2.0000i              5.0000          
                  5.0000                    4.0000

Attributeerror: module “Seaborn” has no attribute “lineplot”

Contents of articles

Preface text

preface

When drawing the diagram, I learned a new library and encountered bugs, but fortunately, I found a solution

text

The specific problem is that the version is wrong, and 0.9 is OK. You can check the version through the command:
PIP freeze | grep Seaborn
or
PIP3 freeze | grep Seaborn
you can check the version through CONDA
CONDA install - C Anaconda Seaborn = 0.9.0
for details Some packages are not included in the default channels of CONDA, such as cudatoolkit-8.0, cudnn, and so on. At this time, you only need to add – C Anaconda after the CONDA install command
or pip:
PIP3 install Seaborn = = 0.9.0
to install the corresponding version
it is recommended to use pip, and the matching image is very fast. There seems to be no network error on the image of CONDA Tsinghua.
Then, there may be version errors in Python 3.6. The following lists the libraries with version problems that I encountered, and gives the possible version
numpy = = 1.15.0
SciPy = = 1.0.0
panda = = 1.0.0

Latex sets page margin, page size, page margin and geometry macro package

Many latex templates have set the margins of the page, so you don’t need to modify them. But sometimes you need to set the margins by yourself. Looking up the relevant information, we find that using the geometry macro package can easily adjust the margins.

\usepackage{geometry}

\geometry{a4paper,scale=0.8}

The above command sets the paper as A4, and the proportion of the page center to the page length is 80%; scale can also be changed to ratio, indicating the proportion of the page margin to the page length. The macro package can also set the top, bottom, left and right margins of the page, for example:

\geometry{a4paper,left=2cm,right=2cm,top=1cm,bottom=1cm}

Greek alphabet pronunciation table and its latex command

Latin alphabet is 26, Greek alphabet is 24, pronunciation is their respective latex form, capital letter is its lowercase latex initial capitalized form, such as(

Δ

When Western mathematicians deduce mathematical theorems, they still use Greek letters which are not easy to write and remember. This shows the great influence of the Renaissance and Greek mathematics on later generations. Pay attention to the distinction

Δ

(pronounced Delta for increment) and

(it’s pronounced nabla, which means differential. It doesn’t belong to the Greek alphabet. It’s just a sign for differential operator.)

lowercase uppercase latex

α

A

\alpha
β

B

\beta
γ

Γ

\gamma

δ

Δ

\delta

ϵ

E

\epsilon
ζ

Z

\zeta
ν

N

\nu
ξ

Ξ

\xi

ο

O

\omicron
π

Π

\pi

ρ

P

\rho
σ

Σ

\sigma

η

H

\eta
θ

Θ

\theta

ι

I

\iota
κ

K

\kappa
λ

Λ

\lambda

μ

M

\mu
τ

T

\tau
υ

Υ

\upsilon

ϕ

Φ

\phi,(

φ

\varphi

χ

X

\chi
ψ

Ψ

\psi

ω

Ω

\omega

What is the schema in the database?

reference resources: http://database.guide/what-is-a-database-schema/

In database, schema (pronounced “skee MUH” or “skee MAH”, called schema in Chinese) is the organization and structure of database. Both schema and schemata can be used as plural forms. Schema objects include table, column, data type, view, stored procedures, relationships, primary key, foreign key, etc. Database schema can be represented by a visual graph, which shows database objects and their relationships

 

The above is a simple example of a schema diagram, showing three tables and their data types, the relationship between tables, and primary and foreign keys. The following is a more complex example of a database schema.

 

In this case, the pattern diagram is divided into four parts

(1) Customer data: data related to customers, such as name, address, etc

(2) Business: data needed by the business, such as employees, store location, payment details, etc

(3) Inventory: details of all products. Here, the product is a movie, so it contains movie title, category, actor and other data.

(4) Views: special views on the data used for evaluation, so we can further create a database through these schema diagrams. In fact, MySQL workbench allows us to generate a create database directly from the diagram Table script, and then we can directly use this script to create a database, and also directly convert a database into a relational chart.

Are schema and database the same?

When it comes to database schema, there are many doubts. The problem often arises whether there is a difference between schema and database, and if so, where is the difference.

It depends on the database vendor

Part of the confusion about schema is that database systems tend to handle schema in their own way

(1) MySQL documents point out that in physics, schema and database are synonymous, so schema and database are the same thing.

(2) However, Oracle documents point out that some objects can be stored in the database, but not in the schema. Therefore, schema and database are not the same thing.

(3) According to this SQL Server technical article, schema is an independent entity within SQL server. So, they are not the same thing.

Therefore, depending on the RDBMS you are using, the schema and database may not be the same.

How to define schema in SQL standard?

In ISO / IEC 9075-1 SQL standard, schema is defined as a persistent, named collection of descriptors. If you are confused about the definition of schema before, I hope it will be better, at least not worse after reading my article.

In a broad sense

Another reason for the confusion may be that the term schema has such a wide range of meanings, because it has different meanings in different environments. The word schema comes from the Greek SKH ē Ma, which means form, figure, shape or plan. In psychology, schema is used to describe the organized thinking or behavior patterns of organizational information categories and their relationships. Before we design a database, we also need to look at the types of information in the data and the relationship between them. Before we start to use the physical schema in DBMS, we need to create a conceptual schema. When discussing patterns in software development, we can discuss conceptual patterns, physical patterns, internal patterns, external patterns, logical patterns, etc., each of which has its own specific meaning.

Schema definition of DBMS

Here are the schema definitions of three leading relational database systems:

MySQL

Conceptually, a schema is a set of interrelated database objects, such as tables, table columns, data types of the columns, indexes, foreign keys, and so on. These objects are connected through SQL syntax, because the columns make up the tables, the foreign keys refer to tables and columns, and so on. Ideally, they are also connected logically, working together as part of a unified application or flexible framework. For example, theINFORMATION_ SCHEMA and performance_ schema databases use “schema” in their names to emphasize the close relationships between the tables and columns they contain.

In MySQL, physically, aschema is synonymous with adatabase. You can substitute the keywordSCHEMA instead ofDATABASE in MySQL SQL syntax, for example using CREATE SCHEMA instead of CREATE DATABASE.

Some other database products draw a distinction. For example, in the Oracle Database product, aschema represents only a part of a database: the tables and other objects owned by a single user.

MySQL official documents point out that conceptually, a schema is a set of interrelated database objects, such as tables, table columns, column data types, indexes, foreign keys, and so on. But from the physical level, schema and database are synonymous. You can use the keyword schema instead of database in the SQL syntax of MySQL, for example, create schema instead of create database .

Reference: MySQL glossary, MySQL 5.7 reference manual. Mysql, retrieved 6 June 2016.

SQL Server

The names of tables, fields, data types, and primary and foreign keys of a database.

SQL Server official documents point out that the schema contains the database table, field, data type and the name of primary key and foreign key. Reference: SQL Server glossary. SQL Server 2016 technical documentation. Microsoft developer network. Retrieved 6 June 2016

Oracle Database

The schema system in Oracle is very different from other database systems. The schema of Oracle is closely related to database users.

A schema is a collection of logical structures of data, or schema objects. A schema is owned by a database user and has the same name as that user. Each user owns a single schema.

Oracle official documents point out that schema is a collection of logical structures of data or schema objects, which is owned by database users and has the same name as the user, that is to say, each user has an independent schema.

Reference: Oracle database objects. Oracle database online documentation 12C release 1 (12.1). Oracle help center. Retrieved 6 June 2016

If you want to know more about schema, you can refer to this article schema definitions by DBMS

Create schema

Although the above three DBMS are different in defining schema, they all support create schema statements.

MySQL

In mysql, create schema creates a database because create schema is synonymous with create database . In other words, you can use create schema or create database to create a database.

Oracle Database

In Oracle, create schema statement does not actually create a schema, because a schema has been created for database users when creating users, that is to say, create user creates a schema in Oracle, create user creates a schema Schema statements allow you to associate schema with tables and views, and authorize them, so that you don’t have to issue multiple SQL statements in multiple transactions.

SQL Server

In SQL server, create schema creates a schema by name. Unlike mysql, the create schema statement creates a schema that is defined separately to the database. Different from Oracle, the create schema statement actually creates a schema (as mentioned earlier, this statement does not create a schema in Oracle). In SQL server, once the schema is created, users and objects can be added to the schema.

summary

The word schema can be used in many different environments. When creating a schema in a specific DBMS, you need to use the DBMS specific definition mode. When you switch to a new DBMS, you must check how the system defines the schema.

Python — using Matplotlib to draw histogram

Python — using Matplotlib to draw histogram

1. Basic histogram

         

First, install Matplotlib( http://matplotlib.org/api/pyplot_ api.html#matplotlib . pyplot.plot )You can use the PIP command to install it directly

# -*- coding: utf-8 -*-
import matplotlib.pyplot as plt

num_list = [1.5,0.6,7.8,6]
plt.bar(range(len(num_list)), num_list)
plt.show()

2. Set color

          

# -*- coding: utf-8 -*-
import matplotlib.pyplot as plt

num_list = [1.5,0.6,7.8,6]
plt.bar(range(len(num_list)), num_list,fc='r')
plt.show()

# -*- coding: utf-8 -*-
import matplotlib.pyplot as plt

num_list = [1.5,0.6,7.8,6]
plt.bar(range(len(num_list)), num_list,color='rgb')
plt.show()

3. Set label

# -*- coding: utf-8 -*-
import matplotlib.pyplot as plt

name_list = ['Monday','Tuesday','Friday','Sunday']
num_list = [1.5,0.6,7.8,6]
plt.bar(range(len(num_list)), num_list,color='rgb',tick_label=name_list)
plt.show()

4. Stacked bar chart

# -*- coding: utf-8 -*-
import matplotlib.pyplot as plt

name_list = ['Monday','Tuesday','Friday','Sunday']
num_list = [1.5,0.6,7.8,6]
num_list1 = [1,2,3,1]
plt.bar(range(len(num_list)), num_list, label='boy',fc = 'y')
plt.bar(range(len(num_list)), num_list1, bottom=num_list, label='girl',tick_label = name_list,fc = 'r')
plt.legend()
plt.show()

5. Side by side bar chart

# -*- coding: utf-8 -*-
import matplotlib.pyplot as plt

name_list = ['Monday','Tuesday','Friday','Sunday']
num_list = [1.5,0.6,7.8,6]
num_list1 = [1,2,3,1]
x =list(range(len(num_list)))
total_width, n = 0.8, 2
width = total_width / n

plt.bar(x, num_list, width=width, label='boy',fc = 'y')
for i in range(len(x)):
    x[i] = x[i] + width
plt.bar(x, num_list1, width=width, label='girl',tick_label = name_list,fc = 'r')
plt.legend()
plt.show()

6. Bar chart

# -*- coding: utf-8 -*-
import matplotlib.pyplot as plt

name_list = ['Monday','Tuesday','Friday','Sunday']
num_list = [1.5,0.6,7.8,6]
plt.barh(range(len(num_list)), num_list,tick_label = name_list)
plt.show()

AttributeError:module“seaborn” has no attribute “lineplot”

When drawing with Seaborn, the following error occurs:

AttributeError: module 'seaborn' has no attribute 'lineplot'

Reason:
the version of Seaborn is a little old. I checked it. The version data of Seaborn is version 0.8.1, and it is lineplot after version 0.9, so I just need to update Seaborn.

pip install -U seaborn

Address of campus mailbox POP3 of Nankai University

text

This semester as a teaching assistant, the mailbox received homework, hundreds of e-mail, manual download attachment is too tired, it is suitable for Python to write an automatic download attachment program. The POP3 address of the mailbox is required for Python to download email attachments. After some trying and searching, we finally found the POP3 address of Nankai campus mailbox: “POP3 mail.nankai.edu .cn”。 Happy to write code to download email attachment.

Python download attachment code

The code I use refers to this blog https://www.cnblogs.com/chouxianyu/p/11270101.html