How can I customise loss functions in scikit-learn library?

How can I use customised loss functions in scikit-learn? For example, instead of using mean squared value, I want to use mean squared value multiplied by the true value of the sample? I have used the following code snippet: def my_custom_loss_func(y_true,y_pred): diff3=(abs(y_true-y_pred))*y_true return diff3

clf=RandomForestRegressor(criterion=my_custom_loss_func)

knn=clf.fit(feam,labm)

I get the following error: KeyError:

On permanents involving trigonometric functions

Here I pose my conjectures on permanents involving trigonometric functions.

Conjecture 1. Let $ p$ be an odd prime. Then both $ $ c_p:=\sqrt p\,\text{per}\left[\cot\pi\frac{jk}p\right]_{1\le j,k\le (p-1)/2}$ $ and $ $ t_p:=\frac1{\sqrt p}\text{per}\left[\tan\pi\frac{jk}p\right]_{1\le j,k\le(p-1)/2}$ $ are integers. Moreover, $ $ c_p\equiv1\pmod p\ \ \text{and}\ \ t_p\equiv (-1)^{(p+1)/2}\pmod p.$ $

Remark 1. Via Mathematica I find that \begin{align}&c_3=1,\ c_5=-4,\ c_7=22,\ c_{11}=1816,\ c_{13}=-5056, \&c_{17}=-2676224,\ c_{19}=58473280. \end{align}

Conjecture 2. Let $ p$ be an odd prime. Then both $ $ s_p:=\frac{2^{(p-1)/2}}{\sqrt p}\text{per}\left[\sin2\pi\frac{jk}p\right]_{1\le j,k\le(p-1)/2}$ $ and $ $ r_p:=\frac{\sqrt p}{2^{(p-1)/2}}\text{per}\left[\csc2\pi\frac{jk}p\right]_{1\le j,k\le(p-1)/2}$ $ are integers. Moreover, $ $ s_p\equiv(-1)^{(p+1)/2}\pmod p\ \ \text{and}\ \ r_p\equiv1\pmod p.$ $

Conjecture 3. Let $ p$ be an odd prime. Then $ $ a_p:=\frac1{2^{(p-1)/2}}\text{per}\left[\sec2\pi\frac{jk}p\right]_{1\le j,k\le(p-1)/2}\in\mathbb Z.$ $ If $ p>3$ and $ p\equiv3\pmod 4$ , then

$ $ \text{per}\left[\sec2\pi\frac{jk}p\right]_{1\le j,k\le (p-1)/2}\equiv \text{per}\left[\cos2\pi\frac{jk}p\right]_{1\le j,k\le (p-1)/2} \equiv-1\pmod p.$ $

Remark 2. Using Galois theory, I have shown that $ a_p,c_p,r_p,s_p,t_p$ are rational numbers for any odd prime $ p$ .

Your comments are welcome!

Special functions for non-elementry antiderivatives.

A lot of functions don’t have elementary antiderivatives. Quite often I observed new special functions were defined that many of them are written in form of these special functions. Example: the dilogarithm, the airy functions, etc… When I looked up the some information I found that there special functions are defined by these integrals themselves. What is the use of such functions? How do they help us in developing mathematics?

Is an interface exposing async functions a leaky abstraction?

I’m reading the book Dependency Injection Principles, Practices, and Patterns and I read about the concept of leaky abstraction which is well described in the book.

These days I’m refactoring a C# code base using dependency injection so that async calls are used instead of blocking ones. Doing so I’m considering some interfaces which represent abstractions in my code base and which needs to be redesigned so that async calls can be used.

As an example, consider the following interface representing a repository for application users:

public interface IUserRepository  {   Task<IEnumerable<User>> GetAllAsync(); } 

According to the book definition a leaky abstraction is an abstraction designed with a specific implementation in mind, so that some implementation details “leak” through the abstraction itself.

My question is the following: can we consider an interface designed with async in mind, such as IUserRepository, as an example of a Leaky Abstraction ?

Of course not all possible implementation have something to do with asynchrony: only the out of process implementations (such as a SQL implementation) do, but an in memory repository does not require asynchrony (actually implementing an in memory version of the interface is probably more difficult if the interface exposes async methods, for instance you probably have to return something like Task.CompletedTask or Task.FromResult(users) in the method implementations).

What do you think about that ?

Partial Injective Functions over Finite Fields

For a partial function $ f: X \to F_q$ , where $ X \subseteq F_q$ be a subset of a finite field $ F_q$ , is there any criterions to judge whether $ f$ is injective?

For $ X=F_q$ , since any function from $ F_q$ to $ F_q$ is a polynomial function, such topic has being discussed using the theory of permutation polynomials; Moreover, criterions only test on the cardinality of $ deg f$ and $ f(F_q)$ was given by Williams, Daqing Wan and Turnwald

For $ X\subsetneq F_q$ case, one can still discuss the problem by considering the polynomials given by Newton Interpolation Formula, is there any similar way to test the injectivity of $ f$ only by testing the cardinality of $ X$ and $ f(X)$ ?

References:

Williams, K. S., On exceptional polynomials, Can. Math. Bull. 11, 279-282 (1968). ZBL0159.05304.

Wan, Daqing, A $ p$ -adic lifting lemma and its applications to permutation polynomials, Mullen, Gary L. (ed.) et al., Finite fields, coding theory, and advances in communications and computing. Proceedings of the international conference on finite fields, coding theory, and advances in communications and computing, held at the University of Nevada, Las Vegas, USA, August 7-10, 1991. New York: Marcel Dekker, Inc. Lect. Notes Pure Appl. Math. 141, 209-216 (1993). ZBL0792.11049.

Turnwald, Gerhard, A new criterion for permutation polynomials, Finite Fields Appl. 1, No. 1, 64-82 (1995). ZBL0817.11055.

Example of convex functions fulfilling a (strange) lower bound

I am reading a preliminary version of a paper which focuses on some minimization problems connected to a class of integral functionals. Reading the assumptions of one of the theorems I cannot convince myself that a “concrete” example exists.

Question. Does there exist a function $ f \colon \mathbb R^N \to [0,+\infty)$ such that

  1. $ f$ is convex;
  2. $ f(\lambda x) = \lambda f(x)$ for any $ \lambda >0$ and $ \forall x \in \mathbb R^N$ ;
  3. there are $ a>0, b \ge 0$ and $ \gamma \in \mathbb R^N$ such that $ $ a|x| \le f(x) + \langle \gamma, x \rangle + b $ $ for any $ x \in \mathbb R^N$ ?

I have some problems in finding a function satisfying the three points… It does not have to be smooth, still I do not see an example.

Generate map with functions in Golang

I have an array of strings which could be generated with different number of elemnts. And I’d like to make a map, where each string from that array will be associated with specific function. Basicly, it might looks like this example, but this code doesn’t work of course:

package main  import "fmt" import "strings"  var (     Names []string {"foo", "bar", "baz"} )  func main() {     m := make(map[string]interface{})     for _, name := range Names {         fnname := strings.Title(name)         // add function to the map         m[name] = fnname     }      // exec functions store in the map     for _, fn := range m {         fn()     } }  func Foo() {     fmt.Println("I'm foo") } func Bar() {     fmt.Println("I'm bar") } func Baz() {     fmt.Println("I'm baz") } 

I’m looking on reflect package, but haven’t found the way how to convert name of supposed function (which is string) to the function itself.