我正在使用Python scikit-learn对从csv获得的数据进行简单的线性回归.
reader = pandas.io.parsers.read_csv("data/all-stocks-cleaned.csv")
stock = np.array(reader)
openingPrice = stock[:, 1]
closingPrice = stock[:, 5]
print((np.min(openingPrice)))
print((np.min(closingPrice)))
print((np.max(openingPrice)))
print((np.max(closingPrice)))
peningPriceTrain, openingPriceTest, closingPriceTrain, closingPriceTest = \
train_test_split(openingPrice, closingPrice, test_size=0.25, random_state=42)
openingPriceTrain = np.reshape(openingPriceTrain,(openingPriceTrain.size,1))
openingPriceTrain = openingPriceTrain.astype(np.float64, copy=False)
# openingPriceTrain = np.arange(openingPriceTrain, dtype=np.float64)
closingPriceTrain = np.reshape(closingPriceTrain,(closingPriceTrain.size,1))
closingPriceTrain = closingPriceTrain.astype(np.float64, copy=False)
openingPriceTest = np.reshape(openingPriceTest,(openingPriceTest.size,1))
closingPriceTest = np.reshape(closingPriceTest,(closingPriceTest.size,1))
regression = linear_model.LinearRegression()
regression.fit(openingPriceTrain, closingPriceTrain)
predicted = regression.predict(openingPriceTest)
Run Code Online (Sandbox Code Playgroud)
最小值和最大值显示为0.0 0.6 41998.0 2593.9
然而,我收到此错误ValueError: Input contains NaN, infinity or a value too large for dtype('float64').
我该如何删除此错误?因为从上面的结果来看,它确实不包含无限或纳米值. …
我正在使用这种语法来创建芯片 -
<md-chips ng-model="someModel" md-separator-keys="seperatorKeys">
<md-chip-template >
<span>{{$chip}}</span>
</md-chip-template>
</md-chips>
Run Code Online (Sandbox Code Playgroud)
这是控制器代码的一部分.
$scope.seperatorKeys = [$mdConstant.KEY_CODE.ENTER, $mdConstant.KEY_CODE.COMMA];
Run Code Online (Sandbox Code Playgroud)
现在我想创建多个芯片,如果我在输入中粘贴逗号分隔字符串来添加芯片,让我们说,例如,如果我输入1234,5678作为输入,它应该创建1234为第一个芯片和5678第二个芯片.
我该如何实现此功能?
<div ng-controller="signupCtrl">
<ul class="list-group" >
<li class="list-group-item">
<div class="form-group">
<input type="text" ng-model="signupCtrl.firstName">
</div>
...
</div>
<div class="form-group">
<div class="pull-right">
<button ng-click="signupCtrl.signupUser()">Register</button>
</div>
</div>
</li>
</ul>
</div>
Run Code Online (Sandbox Code Playgroud)
someAppControllers.controller('signupCtrl', [
'$window',
'$scope',
'HttpReqHandlerService',
'$location',
'localStorageService'],
function($window, $scope, HttpReqHandlerService,
$location, localStorageService) {
$scope.signupUser=function signupUser() {
alert("hello");
}]);
Run Code Online (Sandbox Code Playgroud)
该按钮未在我的控制器中调用signupUser功能
我的指令用法代码
<input-select ng-model="someModel" ng-change="someFunction()"
options="countries"></input-select>
Run Code Online (Sandbox Code Playgroud)
我的指令代码
.directive('inputSelect', function () {
return {
templateUrl: 'someTemplate.html',
restrict: 'E',
scope: {
ngModel: '=',
ngChange: '='
}
};
});
Run Code Online (Sandbox Code Playgroud)
我的指令模板
<select
ng-model="ngModel" ng-init="ngModel "
ng-options="option[optionId] as option[optionName] for option in options"
ng-change="ngChange">
</select>
Run Code Online (Sandbox Code Playgroud)
因此,当所选项被更改时,函数someFunction()将被无限次调用(尽管更改已完成一次),应该更改的内容以确保someFunction()只调用一次(someFunction()是控制器范围内的函数)该指令正在使用中)
[我确实尝试使用&和使用@ngChange的范围类型,somefunction()如果使用它们不会被解雇.]
javascript angularjs angularjs-directive angularjs-scope ng-options
这是我在服务中的代码.
this.loginUser = function(checkUser) {
Parse.User.logIn(checkUser.username, checkUser.password, {
success: function(user) {
$rootScope.$apply(function (){
$rootScope.currentUser = user;
});
}
});
};
Run Code Online (Sandbox Code Playgroud)
这是我在控制器中的代码:
$scope.logIn = function(){
authenticationService.loginUser($scope.checkUser);
console.log($scope.currentUser)
};
Run Code Online (Sandbox Code Playgroud)
所以,我想要做的是,在完成AJAX调用后执行一些代码,其成功函数设置$ scope.currentUser的值,我可以用于某些条件逻辑(如重定向等)成功函数是否正确设置值,但console.log应该在执行authenticationService.loginUser()功能后执行.
在Chrome应用中,我使用JavaScript XHR从服务器下载blob内容(特别是Angular $ http GET,响应类型为'blob')
我该如何将其保存到chrome应用程序的文件系统?
目前在HTML5文件系统API上使用Angular包装器 https://github.com/maciel310/angular-filesystem
我不想向用户显示弹出窗口(因此我无法使用chrome.fileSystem. chooseEntry)
该chrome.fileSystem.requestFileSystemAPI仅受Kiosk专用应用程序支持.因此我使用的是HTML5 FileSystem API而不是chrome.
我正在使用以下代码来使XHR获取blob.
$http({
url: SERVER_URL+"/someVideo.mp4",
method: "GET",
responseType: "blob"
}).then(function(response) {
console.log(response);
fileSystem.writeBlob(response.name, response).then(function() {
console.log("file saved");
}, function(err) {
console.log(err);
});
}, function (response) {
});
Run Code Online (Sandbox Code Playgroud)
这是我的writeBlob方法
writeBlob: function(fileName, blob, append) {
append = (typeof append == 'undefined' ? false : append);
var def = $q.defer();
fsDefer.promise.then(function(fs) {
fs.root.getFile(fileName, {create: true}, function(fileEntry) {
fileEntry.createWriter(function(fileWriter) {
if(append) {
fileWriter.seek(fileWriter.length);
}
var truncated = false; …Run Code Online (Sandbox Code Playgroud) javascript google-chrome angularjs html5-filesystem google-chrome-app
foo.messageData是一个清单.messageData包含name为字符串.
在thymeleaf html模板中,我想打印name第一个元素的属性值messageData.
像这样的东西foo.messageData[0].name:
<span th:text="foo.messageData[0].name"></span>
Run Code Online (Sandbox Code Playgroud)
和
<span th:text="foo.messageData.get(0).name"></span>
Run Code Online (Sandbox Code Playgroud)
不管用.
如何打印这些数据?在Thymeleaf中有没有特定的语法?
我知道这个值可以通过迭代使用来打印th:each; 但我不想要这些迭代.
当我在一个变量中定义了一个组件,并且我试图将它作为子道具传递给一个组件时,Objects are not valid as a React child会显示错误。
这样做的正确方法是什么?
function AnotherComponent(){
return "Another";
}
function ChildComponent(props) {
const { children, value, index, ...other } = props;
console.log(children);
return (
<Typography
component="div"
role="tabpanel"
hidden={value !== index}
id={`full-width-tabpanel-${index}`}
aria-labelledby={`full-width-tab-${index}`}
{...other}
>
<Box p={3}>{children}</Box>
</Typography>
);
}
function MainComponent(){
const tabItems = [
{ "component": AnotherComponent}
];
const [value, setValue] = React.useState(0);
return (
<>
{tabItems.map((tabItem,index) => (
<ChildComponent value={value} index={tabItem.index}>
{tabItem.component}
</ChildComponent>
))}
</>
)
}
Run Code Online (Sandbox Code Playgroud) angularjs ×5
javascript ×4
jquery ×2
ajax ×1
html ×1
html-email ×1
material-ui ×1
ng-options ×1
numpy ×1
python ×1
react-hooks ×1
reactjs ×1
scikit-learn ×1
spring ×1
thymeleaf ×1