点赞发Nature
关注中Science
最近在想怎么用python实现非径向距离函数
之前用了pyDEA包https://pypi.org/project/pyDEA/
,那个包比较简陋,只有普通的CCR BCC模型。
另一方面,MaxDEA因为是打包好的嘛,所以不够灵活。所以想自己做一个NDDF的模型出来。
所以用pyDEA的初始代码进行了一些改造,直接上代码:
import numpy as np
import pandas as pd
import pulp
class DEAProblem:
def __init__(self, inputs, outputs, weight_vector, directional_factor=None, returns='CRS',
in_weights=[0, None], out_weights=[0, None]):
self.inputs = inputs
self.outputs = outputs
self.returns = returns
self.weight_vector = weight_vector # weight vector in directional distance function
self.J, self.I = self.inputs.shape # no of DMUs, inputs
_, self.R = self.outputs.shape # no of outputs
self._i = range(self.I) # inputs
self._r = range(self.R) # outputs
self._j = range(self.J) # DMUs
if directional_factor == None:
self.gx = self